Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read a specific row in excel file using python

I want to read single row from an Excel_file1, Sheet1, Row number 7 using python, any help?

like image 335
Tim Avatar asked Dec 03 '22 18:12

Tim


1 Answers

First install xlrd

pip install xlrd

then open python file and

import xlrd 

# Give the location of the file 
loc = ("path of file") 

# To open Workbook 
wb = xlrd.open_workbook(loc) 
sheet = wb.sheet_by_index(0) 

print(sheet.row_values(7)) 

location is relative path not absolute path.

To read more about xlrd and its usage visit https://xlrd.readthedocs.io/en/latest/

Happy coding.

like image 197
anand_v.singh Avatar answered Dec 20 '22 04:12

anand_v.singh