Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

how to generate a csv file in linux from sql query when data may contain a comma?

3 Answers

Relevance
  • Chris
    Lv 7
    2 years ago

    Apparently the 2017 spec says to wrap every value that contains line breaks, double quotes or commas in double quotes, and to escape double quotes by using two double quotes.

    So three values like this:

    abc

    def, ghi

    "hello"

    is supposed to be stored like this:

    abc,"def, ghi","""hello"""

    Programming languages usually have libraries to deal with this though.

  • 2 years ago

    You can put double quotes around the value of any field that may contain a comma.

  • Anonymous
    2 years ago

    Then you'll have to use an alternative format, such as a semi-colon separated variable, or a tab-separated, etc. Whichever type is least likely to occur within the field itself.

Still have questions? Get your answers by asking now.