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