excel 文件分割
import sys
import pandas as pd
#fname = 'video_file.xlsx'
#num_split = 10
fname = sys.argv[1]
num_split = int(sys.argv[2])
print(fname)
print(num_split)
fname_prefix = fname.split('.')[0]
df = pd.read_excel(fname, sheet_name='Sheet1')
rows_per_split = int(len(df) / num_split)
for i in range(num_split):
if i == num_split - 1:
df_tmp = df[i * rows_per_split: ]
else:
df_tmp = df[i * rows_per_split: (i + 1) * rows_per_split]
df_tmp.to_excel('{}_{}.xlsx'.format(fname_prefix, i), index=False)