I am learning Python on the go and trying to use pandas for the first time as well. I have a directory with about 50 excel workbooks I am trying to combine into one.
import openpyxl
import pandas as pd
import numpy as np
import glob
import os
import sys
#path = "\\\\mtrjesmith\\Service Parts Photography Project\\STERISForms"
files = os.listdir("\\\\mtrjesmith\\Service Parts Photography Project\\STERISForms")
outf = "C:\\Python27\\Scripts\\steris_forms\\compiled.xls", "w+b"
#print(files)
frame = [x.parse(x.sheet_names[0], header=None,index_col=None) for x in files]
frame[1:] = [df[1:] for df in frame[1:]]
combined = pd.concat(frame)
combined.to_excel("C:\\Python27\\Scripts\\steris_forms\\compiled.xls", "w+b", header=False, index=False)
I get the following error:
Traceback (most recent call last):
File "C:\Python27\Scripts\steris_forms.py", line 18, in <module>
frame = [x.parse(x.sheet_names[0], header=None,index_col=None) for x in files]
AttributeError: 'str' object has no attribute 'parse'
What can I do to solve this? Any other feedback would be greatly appreciated.