How to read data from excel file in Python
Python can be used to read data from an excel file. The module called xlrd
is used to retrieve information from a spreadsheet.
Command to install xlrd module:
pip install xlrd
A workbook contains the data in the Excel file.
Input file:
import xlrd location = ("path of file") #to open excel using open_workbook() wb = xlrd.open_workbook(location) # open a sheet using index sheet = wb.sheet_by_index(0) # open a sheet using name of the sheet #print(sheet.sheet_by_name('name_of_sheet')) # printing row 0 and column 0 print(sheet.cell_value(0, 0)) # printing row 0 and column 1 print(sheet.cell_value(0, 1))
Output:
NAME AGE
Subscribe
Login
Please login to comment
0 Discussion