Tag Info

About

CSV is a file format describing a plain text file with information separated by commas (,).

While technically plain text files (.txt), these files are given the .csv extension to indicate that the data is delimited by commas and can be afforded special parsing.

The MIME type for CSV files is text/csv.

Information is often stored as CSV format to make it easy to transfer tables of data between applications. Each row of a table is represented as a list of plain text (human-readable) values with commas as delimiters between each discrete piece of data. Values may be enclosed in quotes, especially if they contain spaces (which might otherwise be parsed as delimiters), or if the data itself contains commas or line breaks. The first row of data often contains the headings of the table columns, which describe the meaning of the data in each column.

Example:

Tabular format:

+-------+-------------+----------+----------------------+
| Time  | Temperature | Humidity | Description          |
+-------|-------------|----------|----------------------+
| 08:00 |     70      |    35    | Sunny and Clear      |
| 11:45 |     94      |    90    | Hazy, Hot, and Humid |
| 14:30 |     18      |          | Freezing             |
+-------+-------------+----------+----------------------+

CSV format:

Time,Temperature,Humidity,Description
08:00,70,35,"Sunny and Clear"
11:45,94,90,"Hazy, Hot, and Humid"
14:30,18,,Freezing

In this example, the first row of CSV data serves as the "header" which describes the corresponding data below it. Each successive line of the CSV file would then neatly fit into the same field as the first line. There is no inherent way to describe within a CSV file whether the first row is a header row or not.

Note that empty fields (fields with no available data, such as the third field in the last line) are place-held with commas so that the fields that follow may be correctly placed.

Questions tagged are expected to relate to programming in some way, for example, parsing/importing CSV files or creating them programmatically.

Related links:

Reference: Stack Overflow SE

history | show excerpt | excerpt history