I've written out code that will concat multiple Excel sheets from a single file into a DataFrame. Then, by using a function, the DF will be split by 1mil rows into mini DFs. Lastly, the mini DFs are converted into CSVs. How can this function work so that it automatically counts how many DFs per 1mil rows to create? Here is my code so far:
data_df = pd.concat(pd.read_excel('file location', sheet_name = None), ignore_index = True)
def automate_excel():
df1 = pd.DataFrame(data_df[0:1000000])
df2 = pd.DataFrame(data_df[1000001:2000000])
df1.to_csv('data_df1', index = False)
df2.to_csv('data_df2', index = False)
automate_excel()
This is a minimized example as the current file is 5mil rows but I can have some up to 10mil rows or broken out into 10 CSV files