I have a dictionary which looks like:
dict = {'a':[1,2,3],
'b':[4,5,6],
'c':[7,8,9]}
I want to write each array into a column in a file, such that the output looks like:
1 4 7
2 5 6
3 6 9
where values are tab separated. So far I have tried:
import csv
with open('text.csv', 'w') as f:
writer = csv.writer(f, delimiter='\t')
for k,array in dict.items():
writer.writerows(zip(array))
But this just prints numbers 1 to 9 in a single column. Can someone help me with this?
(Is there any more efficient way to store multiple arrays like shown in the dictionary such that it becomes easier to write on a file?)