Raise Xlrderror - Indicating Sheet_name Python

Asked

Viewed 63 times

0

Good morning. I’m starting with Python and I have a problem. I have N files in Excel and need to read the sheet_name of each indicating their name, the code I have so far is this:

os.chdir("work path")
fileLista = glob.glob('*.xls')
arqFine= pd.DataFrame()
for arquivo in fileLista:
    df = pd.read_excel(arquivo, sheet_name = ["sheet do arquivo um ","sheet do arquivo dois","sheet do arquivo tres"], skiprows=1).split(',')
    arqFine= pd.concat([arqFine,df])
    arqFine.columns = arqFine.columns.str.strip()

When I do this it returns the error: 'Raise Xlrderror('No sheet named <%r>' % sheet_name)' I don’t understand the reason to return this error, and the name of Sheet is exactly that. And when I put the "sheet = 1" returns me information, but not what I want. Can anyone help me understand the problem? Thank you.

  • The names the spreadsheets are correct?

  • Yes, all the names of the spreadsheets are correct, I even tried to rename to make a test, but still giving the same error.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.