按数据条数拆分TXT
import os
import math
input_file_path = r'\jz\a.xlsx'
split_num = 1000
data = [file for file in open(inpit_file_path,'r',encoding='utf8')]
data_len = len(data)
split_txt_num = math.ceil(data_len/split_num)
for i in range(split_txt_num):
out_put_file=os.path.splitext(input_file_path)[0]+'_'+str(i+1)+os.path.splitext(input_file_path)[1]
if i==split_txt_num - 1:
contents_1 = i*split_num
contents_2 = len(data)
else:
contents_1 = i*split_num
contents_2 = (i+1)*split_num
with open(out_put_file,'w+',encoding='utf8') as wf:
for line in data[contents_1:contents_2]:
wf.write(line)