Read_Excel Pandas Sheet_Name = None returning only 1 Sheet

2859 views python
1

I have an excel workbook with 36 sheets (not my fault). The code below 'works', reads in the file but only the first sheet. I concat and send to csv and the result is only 'Sheet1". Thoughts?

import pandas as pd

Data = pd.read_excel(open("P://XXDrives//Folder_1//Folder_2//XX.xlsx", "rb"), sheet_name = None)

pd.concat([Data], axis=0, ignore_index=True)

Data.to_csv('C://Users//MyName//Desktop//test.csv')

answered question

Reassign the concat.. Data = pd.concat([Data], axis=0, ignore_index=True)

@pyd Take a look here (its been asked a couple of times) ;)

@RR33 Are you trying to append all 35 sheets together?

Still returns only one sheet of data per the reassign. Not sure what you mean about the second question. I tried pd.read_excel(path only) and got the same result.

1 Answer

5

The code is reading only one sheet because you have specified sheet_name = None. If you want it to read specific sheet (lets say a sheet named - 'my_sheet_name'), use sheet_name = 'my_sheet_name'

posted this

Have an answer?

JD

Please login first before posting an answer.