-1

I write a list of tuples to a csv file. Specifically the input would look something like this:

newList = [
    ('02-02-2018','18:06:06'),
    ('01-04-2018','15:08:03'),
    ('23-05-2018','07:10:15'),
]

This is what I've tried:

with open('newCSV.csv','w') as newFile:
    writer = csv.writer(newFile)
    writer.writerow(['date','time'])
    writer.writerows(newList)
newFile.close()

The output file like this :

    date        time
 1  02-02-2018  18:06:06
 2
 3  01-04-2018  15:08:03
 4
 5  23-05-2018  07:10:15

why the output file have blank rows between the rows? can someone help me?

Born Tbe Wasted
  • 610
  • 3
  • 13
elisa
  • 489
  • 5
  • 13

1 Answers1

1

while opening the file specify what need to be printed for the new line

with open('newCSV.csv','w', newline='') as newFile: