我需要一个脚本将主工作表(包含超过50K行)拆分为单独的工作表,这些工作表只包含40行,没有标题
经过一段时间的研究,我成功地创建了一个脚本来分割主工作表。但是,每个工作表都包含原始标题,并且每个工作表的行不会拆分为40行。在
我相信,当你使用panda和数据框拆分工作表时,它们总会包含一个标题?关于如何修改我的python脚本以实现我的需要有什么建议吗?或者有没有一种更简单的方法可以在不需要使用pandas和数据帧的情况下实现这一点?在path = input('Enter file path to workbook name and extension,
e.g. example.xlsx: ')
chunksize = int (input('Enter the row number you want to split the excel sheet at: ') )
destination = input('Enter folder path to where you want the split files stored. Press Enter to save in current location: ')
i = 0
df = pd.read_excel(path)
for chunk in np.array_split(df, len(df) // chunksize):
chunk.to_excel(destination +
'file_{:02d}.xlsx'.format(i), index=True)
i += 1