合并文件夹下的所有excel文件
import pandas as pd
import os
path = r".\excel表格"
# 获取该目录下所有文件,存入列表中
fileList = os.listdir(path)
n = 0
all_df = pd.DataFrame()
for i in fileList:
file_path = path + os.sep + fileList[n]
df = pd.read_excel(file_path)
all_df = pd.concat([all_df, df])
n += 1
all_df.to_excel("all.xlsx", index=False)

浙公网安备 33010602011771号