用Python编写的CSV文件在每一行之间都有空行。import csvwith open('thefile.csv', 'rb') as f:
data = list(csv.reader(f))
import collections
counter = collections.defaultdict(int)
for row in data:
counter[row[10]] += 1with open('/pythonwork/thefile_subset11.csv', 'w') as outfile:
writer = csv.writer(outfile)
for row in data:
if counter[row[10]] >= 504:
writer.writerow(row)
这段代码读thefile.csv,进行更改,并将结果写入thefile_subset1.
但是,当我在MicrosoftExcel中打开结果CSV时,在每个记录之后都会有一个额外的空行!
有没有办法使它不加额外的空行?