python 合并多张excel sheet(全网最简洁代码,有问题欢迎咨询)
#导入要用的包
import pandas as pd
import numpy as np
import os, shutil
#开始合并
excel_path =r"E:\data" #文件夹路径
excel_name = r"销售明细.xlsx" #Excel名
excel_cols = [‘姓名’, ‘人数’, ‘销量’, ‘单价’, ‘总销售额’] #每个sheet的表头
excel_file_name = os.path.join(excel_path , excel_name )
excel_file = pd.ExcelFile(excel_file_name )
pd.concat([pd.read_excel(excel_file,
sheet_name= name,
names= excel_cols)
for name in excel_file.sheet_names],
ignore_index= True).to_csv(excel_path+ r’\excel_combine.csv’, index = False, encoding = ‘gbk’)
python 合并多张excel sheet(全网最简洁代码)
最新推荐文章于 2024-08-08 14:28:23 发布