Tuesday, February 23, 2016

Working with Excel Files

Working with Excel Files

XLRD package is for reading data and formatting information from older Excel files (ie: .xls)

Installing the pkg :

pip install xlrd

Usage :

import xlrd

fil="test.xlsx"  # This is sample file with some data

workbook= xlrd.open_workbook(fil)

Sheet=workbook.sheet_by_name("Data_set1")      #Data_set1 this is the name that is displayed at bottom left cornet over the present working sheet

ccount=Sheet.ncols     #to get the column count

rcount=Sheet.nrows     #to get the row count

for r in range(rcount):
for c in range(ccount) :
val=[Sheet.cell_value(r,c)]
print (str(Sheet.cell_value(r,c)))

No comments:

Post a Comment