CSV (Comma-Seperated Value) Files

Article by:
Date Published:
Last Modified:


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

  1. Each record is located on a different line, and each line is seperated by the carriage return and line break characters (the record delimiter).

  2. The last record in the file may or may not have a record delimiter at the end of it.

    xxx,yyy,zzz CRLF (record delimiter on last line)  


    xxx,yyy,zzz (no record delimiter on last line)  
  3. 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.

    Field1Name, Field2Name, Field3Name  
  4. White-space (space and tab characters) are considered part of the field, and shall be preserved (i.e. not stripped) when parsing CSV files.


There is no “official” standard for CSV files, however, RFC 4180 stands as the defacto standard (it formally registers the MIME type “text/csv”.


Geoffrey Hunter

Dude making stuff.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License .

Related Content:


comments powered by Disqus