I am trying to combine several excel workbooks using jupyter notebook. I named the directory containing the excel workbooks files
and its output is:
['Book10.xls',
'Book13.xls',
'Book12.xls',
'Book16.xls',
'Book9.xls',
'Book15.xls',
'Book14.xls',
'Book8.xls',
'Book18.xls',
'Book4.xls',
'Book6.xls',
'Book3.xls',
'Book1.xls']
I'm using the following loop to try to extract the data into python and paste them together in a larger dataframe:
df = pd.DataFrame()
for file in files:
if file.endswith('.xls'):
df = df.append(pd.read_excel(file), ignore_index=True)
df.head()
However, I'm the getting a path error:
[Errno 2] No such file or directory: 'Book10.xls'
I read a similar thread (Python open() gives FileNotFoundError/IOError: Errno 2 No such file or directory) which mentioned that using an IDE can change the file path. I also tried os.listdr()
and os.getcwd
to double check I'm in the correct directory (which I seem to be).
Any help on figuring out why the file path isn't being recognized and suggestions to get the loop working would be greatly appreciated!