Back

ⓘ Comma-separated values




                                     

ⓘ Comma-separated values

In computing, a comma-separated values file stores information you might find in a spreadsheet, such as a table of text, numbers, and dates, in a plain text file.

                                     

1. Format

Typically, the first line in a plain text file would contain header information, which are labels for table information organized vertically. Starting with the second line, each line would represent a row. Each cell in a row is separated by a comma, hence its name.

The following is a simple example of this type of file. The example has three columns, and four rows including the header line at the top.

                                     

1.1. Format Escaping

Text in a cell may be surrounded by quotation character ", to note the start and end of a cell a particular column and row location in a table. Quotation characters in a cell value in turn can be denoted by doubling the quotation character ". This is primarily used to signify that a particular cell contains data that may be confusing to a computer thats trying to read the file. A common example of this is when a cell contains a comma as part of its data. Without the quotation marks, its unclear if the comma denotes a speperation between cells:

or if it should be part of the cells data:

                                     

2. Compatibility

CSV is a way to describe table data. However, various applications may require different types of tables. Having a file in CSV format may not be enough for a file to be compatible with a particular application.

Furthermore, CSV is stored in plain text. An application may have problems reading a CSV file because of incompatibility with the plain text format, either because of the character encoding or line break format.