Reputation: 125
Trying to print some strings as rows into a csv however, it gets printed as a column . Code is:
with open('test.csv','w') as b:
a = csv.writer(b)
a.writerows(strings)
b.close()
Output is
GGKKKTKICDKVSHEEDRISQ ISEILFHLSTKDSVRTSALST FDSHRDSWIRKLRLDLGYHHD HLDVHCFHDNKIPLSIYTCTT
I would need it as rows like:
GGKKKTKICDKVSHEEDRISQ
ISEILFHLSTKDSVRTSALST
Upvotes: 0
Views: 31
Reputation: 11754
writerows
expects a list of lists - each inner list a row. I assume that strings
is a list of strings, and thus treated like a single row. To covert it to a list of rows, which is what you want, use:
a.writerows([[x] for x in strings])
Upvotes: 1