9
Pythonで記述されたCSVファイルには、各行の間に空白行があります
import csv with open('thefile.csv', 'rb') as f: data = list(csv.reader(f)) import collections counter = collections.defaultdict(int) for row in data: counter[row[10]] += 1 with 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ます。 ただし、結果のcsvをMicrosoft Excelで開くと、各レコードの後に余分な空白行があります。 余分な空白行を入れないようにする方法はありますか?