import pandas as pd
from os import listdir
from os.path import isfile , join
folder = "c:/sheets"
excel_names = [f for f in listdir(folder) if isfile(join(folder, f))]
print(excel_names)
excel_files = []
for item in excel_names:
item = folder + item excel_files.append(item)
# read them in
excels = [pd.ExcelFile(name) for name in excel_files]
# turn them into dataframes
frames = [x.parse(x.sheet_names[0], header=None, index_col=None)
for x in excels]
# delete the first row for all frames except the first
# i.e. remove the header row -- assumes it's the first
frames[1:] = [df[1:] for df in frames[1:]]
# concatenate them..
combined = pd.concat(frames) combined.to_excel(folder+"/combined.xlsx", header=False, index=False)
This is the code I wrote so far but it seems to work for one sheet only in multiple workbook. What should I do?