我有一个xls文件,其中包含多张工作表,我想将所有这些工作表合并为一张,只有一张工作表。
import numpy as np
import pandas as pd
import glob
import os
import xlrd
df = pd.concat(map(pd.read_excel, glob.glob(os.path.join('', "bank.xls"))))
尝试得到警告
WARNING *** file size (25526815) not 512 + multiple of sector size (512)
什么都没发生
答案 0 :(得分:0)
这对我有效(刚刚经过测试)。
import pandas as pd
import sys
input_file = 'C:\\your_path\\Book1.xlsx'
output_file = 'C:\\your_path\\BookFinal.xlsx'
df = pd.read_excel(input_file, None)
all_df = []
for key in df.keys():
all_df.append(df[key])
data_concatenated = pd.concat(all_df,axis=0,ignore_index=True)
writer = pd.ExcelWriter(output_file)
data_concatenated.to_excel(writer,sheet_name='merged',index=False)
writer.save()