I have the following source code, where I am trying to write a list in a csv file. I need every new list to be written in a new line of this csv file. The source code is the
If you use Python 3.x then change your code:
import csv
list1 = [58,100,'dir1/dir2/dir3/file.txt',0.8]
with open("output.csv", "a", newline='') as fp:
wr = csv.writer(fp, dialect='excel')
wr.writerow(list1)
Adding newline='' can help you to avoid getting extra new lines, empty rows in between two rows with data.