合并多个excel表格

合并多个EXCEL 

"""
import os
import pandas as pd
import xlwt, xlrd
from GINA_START.gina_baseinfo import baseinfo

# 实例化
baseinfo = baseinfo()
path = r'F:\小高天天乐\锚点取值\2.0项目\建设_债承项目\债承项目\债承1.0'
file_list = os.listdir(path)

df = pd.DataFrame()
for file_name in file_list:
    if file_name.endswith('.xlsx'):
        print("-----------------", file_name)
        file_path = os.path.join(path, file_name)
        file_conect = pd.read_excel(file_path, sheet_name='业务锚点')
        # columns = file_conect.columns
        file_conect.columns = file_conect.loc[0, :].values.tolist()
        file_conect = file_conect.loc[1:, :]
        df = df.append(file_conect)

print(df)
df.to_excel(r'F:\小高天天乐\锚点取值\2.0项目\建设_债承项目\债承项目\债承1.0\data.xlsx')

 

posted @ 2022-11-03 21:30  yongqi-911  阅读(78)  评论(0编辑  收藏  举报