import csv
import os
NEW_CSV = ".\\generate"
def trans_format(txt_path=""):
if os.path.exists(txt_path):
with open(txt_path, encoding='utf-8') as f:
txt_row = "123"
count = 0
index = 0
while txt_row:
txt_row = f.readline()
txt_row_list = txt_row.split('\t')
open_csv = open(NEW_CSV+str(count)+'.csv', 'a+',encoding='utf-8')
csv_writer = csv.writer(open_csv)
csv_writer.writerow(txt_row_list)
open_csv.close()
index += 1
if (index % 10000 == 0):
count = count+1
else:
print('can not transform')
return
if __name__ == "__main__":
trans_format(".\\two")
网友评论