简体   繁体   中英

Python (replit): Import excel file with xlrd error

I am a beginner in python, and I have the following (embarassing) issue:

I am trying to import an excel file using xlrd but I have the "FilenotfoundError".

Anyone is able to help a newbie?

Thanks a lot, Matteo

-- import xlrd

#load the data file path =(r"C:\Users\MCECCHI\Desktop\oil_exxon.xls")

wb = xlrd.open_workbook(path) sheet = wb.sheet_by_index(0)

print(sheet.nrows)

You should try to pip install xlrd and It can be done like this

Program to extract number

of rows using Python

import xlrd

Give the location of the file

loc = (r"C:\Users\MCECCHI\Desktop\oil_exxon.xls")

wb = xlrd.open_workbook(loc)

sheet = wb.sheet_by_index(0)

sheet.cell_value(0, 0)

Extracting number of rows

print(sheet.nrows)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM