python txt转换csv 快速

2022-06-12 15:14:03 浏览数 (1)

代码语言:javascript复制
import csv
csvFile = open("/Users/wyc/work/geneSearch/server/search/datas_train.csv",'w',newline='',encoding='utf-8')
writer = csv.writer(csvFile)
csvRow = []

f = open("/Users/wyc/work/geneSearch/server/search/test-20220607.txt",'r')
for line in f:
    csvRow = line.split()
    writer.writerow(csvRow)

f.close()
csvFile.close()

0 人点赞