I have probably hundreds or thousands small excel file with bracket into one pandas dataframe
Here's my table of reference df
Dataframe_name Path Sheet
45 finance_auditing Finance - Accounting/TopSites-Fin... Aggregated_Data_for_Time_Period
46 finance_lending Finance - Banking/TopSites-... Aggregated_Data_for_Time_Period
What I did
finance_auditing = pd.read_excel('Finance - Accounting/TopSites-Fin... ','Aggregated_Data_for_Time_Period')
finance_lending = pd.read_excel('Finance - Banking/TopSites-... ','Aggregated_Data_for_Time_Period')
all = finance_auditing.append(finance_lending)
The problem is I have hundreds of of file to read and need to append them all
You can use list comprehension to iterate over the pairs of path and sheet and read the corresponding excel file, finally concat
all the excel files:
pd.concat([pd.read_excel(path, sheet_name=sheet)
for path, sheet in zip(df.Path, df.Sheet)])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.