Read Excel from Python
First we need to import xlrd module
then open the workbook and read cell by cell
Complete code given below-
import xlrd
#loc = (r'C:\Users\xyz\Python_Local\MyExcel.xls')
#print(loc)
wb = xlrd.open_workbook(r'C:\Users\xyz\Python_Local\File1.xls')
sheet = wb.sheet_by_index(0)
# For row 0 and column 0
sheet.cell_value(0, 0)
# Extracting number of columns
print(sheet.ncols)
# Extracting number of rows
print(sheet.nrows)
Comments
Post a Comment