I need to write into a csv file using python and each iterator item should start in a new line. So delimiter I am using is \"\\n\". After each list has been written,next lis
If you are using Python3 you need to open files in text format "wt", more over csv has writerows that can be used to write everything at once. here is an example:
data=[("test", "value1", "value2"), ("test2", "value3", "value4")]
with open('my.csv','wt') as out:
csv_out=csv.writer(out)
csv_out.writerows(data)
I've just noticed that the question ask how to transform the list, that is a separate step and here is how I would do it:
lol = [[1,2,3],[4,5,6]]
data = zip(lol[0],lol[1])