Created
October 28, 2019 08:17
-
-
Save bhuiyanmobasshir94/b732a2dc84af392138312f07ecd5bb1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install modin[all] | |
# import modin.pandas as mpd | |
import pandas as pd | |
import math | |
def handler(df, n_rows, file_name): | |
if df.shape[0] >= n_rows: | |
split_index_ = int(df.index[0]) + n_rows | |
split_index = n_rows | |
new_df = df.iloc[:split_index,:] | |
new_file_name = str(split_index_) + '_' + file_name | |
new_df.to_excel(new_file_name) | |
df.drop(new_df.index.values, inplace = True) | |
elif df.shape[0] > 0: | |
new_file_name = str(df.shape[0]) + '_' + file_name | |
df.to_excel(new_file_name) | |
def split_excel_row(n_split=None, file_name='EA_May_2019_For_Rabbul.xlsx'): | |
try: | |
df = pd.read_excel(file_name) | |
if n_split and type(n_split) == int: | |
split_index = math.ceil(df.shape[0] / n_split) | |
for i in range(n_split): | |
handler(df, split_index,file_name) | |
except Exception as e: | |
print(e) | |
split_excel_row(n_split=5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment