import csv
with open(\'thefile.csv\', \'rb\') as f:
data = list(csv.reader(f))
import collections
counter = collections.defaultdict(int)
for row in data:
Use the method defined below to write data to the CSV file.
open('outputFile.csv', 'a',newline='')
Just add an additional newline=''
parameter inside the open
method :
def writePhoneSpecsToCSV():
rowData=["field1", "field2"]
with open('outputFile.csv', 'a',newline='') as csv_file:
writer = csv.writer(csv_file)
writer.writerow(rowData)
This will write CSV rows without creating additional rows!