-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.py
29 lines (22 loc) · 804 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pandas as pd
import tkinter as tk
from tkinter import filedialog
# Create a Tkinter root window
root = tk.Tk()
root.withdraw() # Hide the Tkinter window
# File selection dialog
file_path = filedialog.askopenfilename(title="Select an Excel file", filetypes=[("Excel files", "*.xlsx *.xls")])
if file_path:
# Read the main Excel file
df = pd.read_excel(file_path)
# Specify the number of rows per chunk
chunk_size = 1000
# Split the file into chunks
for i in range(0, len(df), chunk_size):
chunk = df.iloc[i:i + chunk_size]
chunk_file_path = f'part_{i // chunk_size + 1}.xlsx'
chunk.to_excel(chunk_file_path, index=False)
print(f'{chunk_file_path} created.')
print("File splitting completed.")
else:
print("No file selected.")