Python 将多个excel表格合成一个

学了半天,总算搞会了

看代码:

import pandas as pd
import numpy as np
import glob
filearray=[]
filelocation="文件地址"
for filename in glob.glob(filelocation+"*.xlsx"):
    filearray.append(filename)
res=pd.read_excel(filearray[0])
for i in range(1,len(filearray)):
    A=pd.read_excel(filearray[i])
    res=pd.concat([res,A],ignore_index=True)
print(res.index)
writer = pd.ExcelWriter('output.xlsx')
res.to_excel(writer,'sheet1')
writer.save()

猜你喜欢

转载自blog.csdn.net/Gipsy_Danger/article/details/80170574