So I've been trying to code a script which loads all excel files from a specific location and moves worksheets inside these files into one workbook. I'm ending with and error:
AttributeError: 'DataFrame' object has no attribute 'DataFrame'
.
I'm pretty new to this so I would really appreciate any tip on how to make that work. I can stick only with openpyxl because at the moment I cannot install xlrd module on my workstation.
from pandas import ExcelWriter
import glob
import pandas as pd
import openpyxl
writer = ExcelWriter("output.xlsx")
for filename in glob.glob (r"C:\path\*.xlsx"):
wb = openpyxl.load_workbook(filename)
for ws in wb.sheetnames:
ws = wb[ws]
print (ws)
data = ws.values
columns = next(data)[0:]
df= pd.DataFrame(data, columns=columns)
print(df)
for df in df.DataFrame:
df.to_excel([writer,sheet_name= ws)
writer.save()