Wizard Book


Programming Python, Web, Android

Python : Membaca/Import File Excel dengan Pandas

Membaca File Excel untuk Diimport sangat mudah menggunakan Python Pandas

import pandas as pd

dfs = pd.read_excel("test.xlsx", sheet_name=None)
print("Hasil Baca Seluruh WorkBook:")
print(dfs)
print("")

print("Nama2 sheet")
for df in dfs:
    print(df)
print("")

from pandas import read_excel

print("Isi Sheet1 (pandas dataframe)")
my_sheet = 'Sheet1'
file_name = 'test.xlsx' # name of your excel file
df = read_excel(file_name, sheet_name = my_sheet)
print(df.head()) # shows headers with top 5 rows
print("")

print("Isi Sheet1 (array)")
for index, row in df.iterrows():
    print(str(row[0]) + " " + str(row[1]) + " " + str(row[2]))

email : contohprogram.com@gmail.com
WA : +6289671400363