合并文件夹下的所有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)

本文作者:tiansz

本文链接:https://www.cnblogs.com/tiansz/p/16872785.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   tiansz  阅读(77)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起