python3把txt文件转换为csv文件
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import csv
with open('file.csv','a',newline='') as csvfile:
spamwriter = csv.writer(csvfile, dialect='excel')
with open('data_2016_1.txt', 'rb') as filein:
for line in filein:
line_list = line.decode().split('\t')
spamwriter.writerow(line_list)