A comma-separated values (CSV) file stores tabular data (numbers and text) as plain text, with rows and columns delimited by line terminators and commas, respectively. You may also use this tag for variants where fields are separated by tabs or semicolons.

Comma-separated values is a common, relatively simple file format that is widely supported by consumer, business, and scientific applications. Among its most common uses is moving tabular data between programs that natively operate on incompatible (often proprietary and/or undocumented) formats. This works because so many programs support some variation of CSV at least as an alternative import/export format.

CSV formats are best used to represent sets or sequences of records in which each record has an identical list of fields. This corresponds to a single relation in a relational database, or to data (though not calculations) in a typical spreadsheet.


Basic rules

RFC 4180 attempts to standardize CSV, but many programs do not follow the standard strictly.

  • CSV is a delimited data format that has fields/columns separated by the comma character and records/rows terminated by newlines.

  • A CSV file does not require a specific character encoding, byte order, or line terminator format (some software does not support all line-end variations).

  • A record ends at a line terminator. However, line-terminators can be embedded as data within fields, so software must recognize quoted line-separators (see below) in order to correctly assemble an entire record from perhaps multiple lines.

  • All records should have the same number of fields, in the same order.

  • Fields may be quoted, usually with double quotes, to allow literal commas to be represented.

history | excerpt history