CSV (Comma-Seperated Value) Files
Terminology
A CSV file is made up of many records, where a record is a single entire line in the file. Each new line is signified with the record delimiter (typically a carriage return and line feed character, CRLF
or \r\n
). A record is made up of many fields, each which a seperated by the field delimiter (typicallay a comma or a tab character).
General Rules
-
Each record is located on a different line, and each line is seperated by the carriage return and line break characters (the record delimiter).
-
The last record in the file may or may not have a record delimiter at the end of it.
or
-
There is an optional header record at the top of the file (the first line), with the same format as the rest of the records. The header contains names/descriptions of the fields in the file.
-
White-space (space and tab characters) are considered part of the field, and shall be preserved (i.e. not stripped) when parsing CSV files.
Standards
There is no “official” standard for CSV files, however, RFC 4180 stands as the defacto standard (it formally registers the MIME type “text/csv”.