阿毛Alex - 2020年10月16日
type: channel
link: https://alexmao.com/index.php/2020/10/16/
description: 生命不息，折腾不止
items: Python合并多个Excel文件

Python合并多个Excel文件
type: item
date: 2020-10-16T02:55:00+00:00
description: 网上抄的一段代码，可以把多个文件合并起来。import pandas as pd file1='jan.xls' file2='feb.xls' file3='mar.xls' file4='apr.xls' file5='may.xls' file6='jun.xls' file7='jul.xls' file8='aug.xls' file9='sep.xls' file=[file1,file2,file3,file4,file5,file6,file7,file8,file9] li=[] for i in file: li.append(pd.read_excel(i)) writer = pd.ExcelWriter('output.xls') pd.concat(li).to_excel(writer,'Sheet1',index=False) writer.save()