excel_splitting/poli.py

21 lines
493 B
Python
Raw Permalink Normal View History

2024-11-23 12:01:14 +03:00
# -*- coding: cp1251 -*-
import pandas as pd
ROWS_PER_FILE = 199
df = pd.read_excel('FILENAME.xlsx')
ROWS_PER_FILE = 199
num_files = (len(df) // ROWS_PER_FILE) + (1 if len(df) % ROWS_PER_FILE > 0 else 0)
for i in range(num_files):
start_row = i * ROWS_PER_FILE
end_row = start_row + ROWS_PER_FILE
df_subset = df.iloc[start_row:end_row]
output_filename = f'File_{i + 1}.xlsx'
df_subset.to_excel(output_filename, index=False)
print(f'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> {num_files} <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.')