CSV file written with Python has blank lines between each row

后端 未结 9 1578
青春惊慌失措
青春惊慌失措 2020-11-21 10:04
import csv

with open(\'thefile.csv\', \'rb\') as f:
  data = list(csv.reader(f))
  import collections
  counter = collections.defaultdict(int)

  for row in data:
          


        
9条回答
  •  别跟我提以往
    2020-11-21 10:37

    with open(destPath+'\\'+csvXML, 'a+') as csvFile:
        writer = csv.writer(csvFile, delimiter=';', lineterminator='\r')
        writer.writerows(xmlList)
    

    The "lineterminator='\r'" permit to pass to next row, without empty row between two.

提交回复
热议问题