Reading Excel File in Python

Sample Excel Sheet



import pandas as pd
f = pd.ExcelFile("customers.xlsx")
dfs = {sheet_name: f.parse(sheet_name)
          for sheet_name in f.sheet_names}
s=dfs["Sheet1"]

#print(s)

#print column names only
for r in s:
    print(r,end=" ")
print()

#print the column data
for i in range(len(s)):
    for r in s:
        print(s.at[i,r],end=' ')
    print()
i=0   

Output



Comments

Popular posts from this blog

Converting Excel File to JSON File using xlrd module

Using Oracle with Python

Using time module