I have a tuple in which one element is just a string and the other is a list (‘x’,[‘y’,’z’]), I want to output the tuple into a csv file with all of the different elements on the same row, but different blocks.
Here is what I have so far
outputwriter=csv.writer(open('output.csv','wb'), delimiter=' ')
for tup in in_tup:
print (tup[0]+' '.join('%s' %x for x in tup[1]))
outputwriter.writerow(tup[0]+' ' +' '.join('%s' %x for x in tup[1]))
when i first print the tuple the output is this
xxxx.com 164.44.xx.xx 164.44.xx.xx 164.44.xx.x
...
But when I output it to the csv I get all of the text in a signle block “A1” and so on. I tried a delimiter when I open the csv writer but it doesn’t work. Any thoughts
1 Answer