【原创】3行代码搞定:Python批量实现多Excel多Sheet合并

老规矩:题目来自群友求助

 

 

 输出

import pandas as pd
import os

path="./Unmerge/"
outfile='result.xlsx'
pd.concat([
    pd.read_excel(xlsxi, sheet_name=sheet_name) for xlsxi in [path + x for x in os.listdir(path) if x.endswith(".xlsx")]
    for sheet_name in list(pd.read_excel(xlsxi, sheet_name=None))
]
, ignore_index=True).to_excel(outfile,index=None)

看了下,96ms

executed in 96ms, finished 11:46:44 2021-10-23

其他群友答案:

------------------------------- ********厚德达理,励志勤工******** -------------------------------
原文地址:https://www.cnblogs.com/hightech/p/15442868.html