I have one excel with large data. I want to split this excel into multiple excel with equal distribution of rows.
My current code is working partially as it is distributing required number of rows and creating multiple excel. but at the same time it is keep creating more excel by considering the rows number.
In n_partitions if I put number 5 then it is creating excel with 5 rows in two excel and after that it keeps creating three more blank excel. I want my code to stop creating more excel after all the rows gets distributed.
Below is my sample excel with expected result and sample code.
Code I am currently using is.
import pandas as pd
df = pd.read_excel("C:/Zen/TestZenAmp.xlsx")
n_partitions = 5
for i in range(n_partitions):
sub_df = df.iloc[(i*n_partitions):((i+1)*n_partitions)]
sub_df.to_excel(f"C:/Zen/-{i}.xlsx", sheet_name="a")




