Search code examples
pythonarrayscsvwriter

Writing array in single csv column


I am trying to write an array like this into csv column

x= ['syz@gmail.com','lpu@gmail.com']

how i can write the same array into one csv column like this

syz@gmail.com,lpu@gmail.com

Thanks


Solution

  • 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))