Soldato
Hi all.
I can find numerous examples scripts online, however, I can't get anything to work
I have a path with lots of small xlsx files (say \\server\folder\ )
I am hoping to combine these into one xlsx worksheet, so that if the final row of file a is row 20, then row 21 will be the first row of file b.
I don't care about formatting header rows or anything like that.
I don't seem to be able to use an xlrd library, but seem to able to run openpyxl
I found the above somewhere online and it seems to run, but it gives the error
Can anyone assist or point me in the right direction? My python experience solely consists of finding and adapting other people's scripts
Thanks
I can find numerous examples scripts online, however, I can't get anything to work
I have a path with lots of small xlsx files (say \\server\folder\ )
I am hoping to combine these into one xlsx worksheet, so that if the final row of file a is row 20, then row 21 will be the first row of file b.
I don't care about formatting header rows or anything like that.
I don't seem to be able to use an xlrd library, but seem to able to run openpyxl
Code:
import numpy as np
import pandas as pd
import openpyxl
import os
import glob
all_names = []
for x in os.listdir(r'\\server\inputfolder'):
if x.endswith(".xlsx"):
all_names.append(x[:-5])
print(all_names)
all_data = pd.DataFrame()
for f in glob.glob("*.xlsx"):
df = pd.read_excel(f)
all_data = all_data.append(df,ignore_index=True)
appended_df = pd.concat((all_data), keys=(all_names))
appended_df.to_excel(r"\\server\outputfolder")
I found the above somewhere online and it seems to run, but it gives the error
first argument must be an iterable of pandas objects, you passed an object of type "DataFrame"
Can anyone assist or point me in the right direction? My python experience solely consists of finding and adapting other people's scripts
Thanks