我有一个CSV文件,我想将每行CSV文件解压缩到不同的CSV文件中。我怎样才能做到这一点?
答案 0 :(得分:0)
像这样,它将保存在按行数
计算的文件中 import csv
with open('file.csv', 'r') as csv_file:
rows = csv.reader(csv_file, skipinitialspace=True)
for i, row in enumerate(rows):
with open('file_{}.csv'.format(i), 'w') as write_file:
writer = csv.writer(write_file)
writer.writerow(row)