RaspiBerry Blog

CnLiutiezhu is here!

Python使用9行代码批量合并Excel文件

| 暂无评论

import os
import pandas as pd
excels=[pd.read_excel(fname)
        for fname in os.listdir("./")
        #if ".xlsx" in fname
        if ".xls" in fname
]
df =pd.concat(excels)
df.to_excel("结果文件.xlsx",index=False)

发表回复

*为必填字段!