So I have 1500 Excel Workbooks, each with 10+ sheets with exactly same structure. I tried to combine Multiple Excel Workbooks into one file and succeeded using code below:
import os
import pandas as pd
cwd = os.path.abspath('')
files = os.listdir(cwd)
df = pd.DataFrame()
for file in files:
if file.endswith('.xlsx'):
df = df.append(pd.read_excel(file), ignore_index=True)
df.head()
df.to_excel('Combined_Excels.xlsx')
And as a result I get combined Excel Workbook, but only with 1st sheets(pages) of each Excel Workbook.
I figured that I need to add a parameter sheet_name=None
, but this way my dataframe becomes a dict
type and when appended, the result is not quite what I wanted.
import os
import pandas as pd
cwd = os.path.abspath('')
files = os.listdir(cwd)
df = pd.DataFrame()
for file in files:
if file.endswith('.xlsx'):
df = df.append(pd.read_excel(file, sheet_name=None), ignore_index=True)
df.head()
df.to_excel('Combined_Excels.xlsx')
Have you guys had similar problems? How can I at least combine all sheets into one? Combining Multiple Excel Sheets would not be a problem imo as the first sample worked perfectly.
Thanks, Nurbek