import csv
csvFile = open("./data.csv",'w',newline='')
writer = csv.writer(csvFile)
csvRow = []
f = open("data.txt",'r')
for line in f:
csvRow = line.split()
writer.writerow(csvRow)
f.close()
csvFile.close()
运行这个可以生成CSV,但是不能批量生成,只是1个。
csvFile = open("./data.csv",'w',newline='')
writer = csv.writer(csvFile)
csvRow = []
f = open("data.txt",'r')
for line in f:
csvRow = line.split()
writer.writerow(csvRow)
f.close()
csvFile.close()
运行这个可以生成CSV,但是不能批量生成,只是1个。