I got a problem with writing a csv file in way that i want.
Description:
I got 3 lists:
list1=[1,2,3]
list2=['dd1','dd2','dd3']
list3=['vi1','vi2','vi3']
I want to write my csv file like:
Column 1| Column 2| Column 3
Row 1 1| dd1| vi1
Row 2 2| dd2| vi2
Row 3 3| dd3| vi3
So i use zip
method like this:
csvd = zip(list1, list2, list3)
After zipping i have:
csvd = [(1, 'dd1', 'vi1'), (2, 'dd2', 'vi2'), (3, 'dd3', 'vi3')]
And next i use csv writer like this:
with open('path\\test.csv', 'w') as f:
writer = csv.writer(f, delimiter='\t')
writer.writerows(csvd)
This is my output: csv
First thing is that, there is every touple in first column (i want each element of touple to be in different column). Second problem is that i got an empty lines between nexts touples.
I tried to solve my problem with just writerow
and for loop
but this is only solution for my second problem, with this method i still got every touple in first column.