Comma-separated values
From Wikipedia, the free encyclopedia
Comma-separated values | |
File extension: | .csv |
---|---|
MIME type: | text/csv |
The comma-separated values (or CSV; also known as a comma-separated list or Comma-Separated Variable) file format is a file type that stores tabular data. The format dates back to the days of mainframe computing. For this reason, CSV files are common on all computer platforms.
CSV is one implementation of a delimited text file, which uses a comma to separate values. However CSV differs from other delimiter separated file formats in using a " (double quote) character around fields that contain reserved characters (such as commas or newlines). Most other delimiter formats either use an escape character such as a backslash, or have no support for reserved characters.
In computer science terms, this type of format is called a "flat file" because only one table can be stored in a CSV file. Most systems use a series of tables to store their information, which must be "flattened" into a single table, often with information repeated over several rows, to create a delimited text file.

Contents |
[edit] Specification
While no formal specification for CSV exists, RFC 4180 describes a common format and establishes "text/csv" as the MIME type registered with the IANA.
Many informal documents exist that describe the CSV format. How To: The Comma Separated Value (CSV) File Format provides an overview of the CSV format in the most widely used applications and explains how it can best be used and supported.
The basic rules are as follows:
CSV is a delimited data format that has fields/columns separated by the comma character and records/rows separated by newlines. Fields that contain a special character ( comma, newline, or double quote ), must be enclosed in double quotes. However, if a line contains a single entry which is the empty string, it may be enclosed in double quotes. If a field's value contains a double quote character it is escaped by placing another double quote character next to it. The CSV file format does not require a specific character encoding, byte order, or line terminator format.
[edit] Example
1997 | Ford | E350 | ac, abs, moon | 3000.00 |
1999 | Chevy | Venture "Extended Edition" | 4900.00 | |
1996 | Jeep | Grand Cherokee | MUST SELL! air, moon roof, loaded |
4799.00 |
The above table of data may be represented in CSV format as follows:
1997,Ford,E350,"ac, abs, moon",3000.00 1999,Chevy,"Venture ""Extended Edition""",,4900.00 1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00
[edit] Application support
The CSV file format is very simple and supported by almost all spreadsheets and database management systems. Many programming languages have libraries available that support CSV files. Even modern software applications support CSV imports and/or exports because the format is so widely recognized. Many applications in fact allow .csv-named files to use any delimiter character.
[edit] See also
[edit] External links
- RFC 4180: Common Format and MIME Type for Comma-Separated Values (CSV) Files
- How To: The Comma Separated Value (CSV) File Format