Why does a program write data out with quotes around variable names?

  • 1
    $\begingroup$ Consider a CSV file where you want to write a city/state combination in a column e.g. Miami, FL. If you don't put quotes around that, then your parsing code (split by comma) will interpret that as two pieces of data instead of one. I have been burned on this, and talking to others who work with CSV files, all of them have been, too. $\endgroup$
    – Dave
    Oct 15, 2020 at 14:23

1 Answer 1


The reason is to distinguish between fields containing delimiters (newline, comma) and delimiters themselves. One example of this pattern can be found in this RFC memo.

Y. Shafranovich. "Common Format and MIME Type for Comma-Separated Values (CSV) Files." October 2005. The Internet Society. Network Working Group.

  1. Each field may or may not be enclosed in double quotes (however some programs, such as Microsoft Excel, do not use double quotes at all). If fields are not enclosed with double quotes, then double quotes may not appear inside the fields. For example:

    "aaa","bbb","ccc" CRLF zzz,yyy,xxx

  2. Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes. For example:

    "aaa","b CRLF bb","ccc" CRLF zzz,yyy,xxx

  3. If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be escaped by preceding it with another double quote. For example:



Not the answer you're looking for? Browse other questions tagged or ask your own question.