python把工作簿拆分为工作表_使用Python和Pandas将Excel工作表拆分为单独的工作表...

我需要一个脚本将主工作表(包含超过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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值