Reputation: 392
I am trying to write an array like this into csv column
x= ['[email protected]','[email protected]']
how i can write the same array into one csv column like this
[email protected],[email protected]
Thanks
Upvotes: 0
Views: 1051
Reputation: 168
This will work for what you're trying to do.
import csv
x = ['[email protected]','[email protected]']
csvOpen = open("yourCSV.csv", 'wb')
out_csv = csv.writer(csvOpen)
out_csv.writerow(x)
csvOpen.close()
Upvotes: 1
Reputation: 23171
It really depends on what is importing your CSV. There is no official standard for CSV but RFC 4180 provides a spec that a lot of people implement. If you follow that, you can simply surround your field in quotes. So in python, this would be:
str.format('"{}"',str.join(",",x))
Upvotes: 0