【原创】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

 

 

 

其他群友答案:

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM