File format reference

CSV file: what it is, the rules and a sample

What is inside a CSV file, the seven rules RFC 4180 writes down, a short sample, and why no single standard exists.

Short answer

A CSV file is a plain-text file of comma-separated values: one record per line, fields separated by commas, and an optional first line of field names. RFC 4180 documents the format and registers the text/csv MIME type, but it is an informational memo and says it does not specify an Internet standard of any kind.

What is inside

RFC 4180's abstract says it documents the format used for Comma-Separated Values (CSV) files and registers the MIME type text/csv. Microsoft describes the same kind of file as "comma separated values text files (.csv), in which the comma character (,) typically separates each field of text."

The first four rules of RFC 4180, section 2
RuleWhat the RFC says
1. Records"Each record is located on a separate line, delimited by a line break (CRLF)."
2. Last line"The last record in the file may or may not have an ending line break."
3. HeaderThere may be an optional header line as the first line, with names for the fields, and it "should contain the same number of fields as the records in the rest of the file".
4. Fields"Within the header and each record, there may be one or more fields, separated by commas." Each line should contain the same number of fields throughout the file. "Spaces are considered part of a field and should not be ignored." "The last field in the record must not be followed by a comma."

A sample

Date,Symbol,Description,Side,Quantity,Price,Fees2026-03-02,EXMP,EXAMPLE INC,Buy,100,48.20,4.952026-03-09,EXMP,EXAMPLE INC,Sell,100,51.10,4.952026-03-10,EXMB,"EXAMPLE BANK, CLASS A",Buy,10,20.00,1.00
Synthetic trades file (invented rows). The last data row has a comma inside a quoted field.

The first line is a header. Every line has seven fields. The description on the last line contains a comma, so the field is wrapped in double quotes. The guide to commas and quotes in CSV covers that rule.

Quotes, commas and line breaks

Rules 5 to 7 of RFC 4180, section 2
RuleWhat the RFC says
5. Quoting"Each field may or may not be enclosed in double quotes". If fields are not enclosed with double quotes, then "double quotes may not appear inside the fields."
6. What needs quotes"Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes."
7. Quotes inside quotes"If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be escaped by preceding it with another double quote."

No single standard

The RFC's introduction says that while the format is very common, "it has never been formally documented." Section 2 adds that "there is no formal specification in existence, which allows for a wide variety of interpretations of CSV files." The memo's status line says it "provides information for the Internet community" and "does not specify an Internet standard of any kind", and its category is Informational.

In practice that means programs differ. The RFC notes in rule 5 that some programs, such as Microsoft Excel, do not use double quotes at all. Microsoft says the separator in a .csv file can be changed and that, when a workbook is saved as .csv, "the default list separator (delimiter) is a comma." The text/csv registration also defines a "header" parameter with the values present or absent, and a "charset" parameter.

Opening a CSV in Excel

Excel interprets each column of a CSV when it opens it, which is where dates and leading zeros go wrong. The guide to opening a CSV in Excel goes through the options, and Excel and CSV compared lists the limits.

Common questions

What does CSV stand for?
Comma-Separated Values. RFC 4180 uses that name in its abstract.
Is CSV an official standard?
No. RFC 4180 is an informational memo, and it says it does not specify an Internet standard of any kind.
Does a CSV file need a header line?
No. RFC 4180 calls the header line optional.
Can a field contain a comma?
Yes, if the field is enclosed in double quotes. RFC 4180 says fields containing commas should be enclosed in double-quotes.
What if a field contains a double quote?
The field is enclosed in double quotes and each double quote inside it is written twice, per rule 7.

What Statementizer does with this

Statementizer reads supported broker statement PDFs into rows you can review, and exports them to Excel or CSV. The CSV export is for programs that take plain text.

See what Statementizer converts

Sources

The rules and quotes are from RFC 4180 (Y. Shafranovich, October 2005, category Informational), read on 2026-11-12; the page notes that the RFC was updated, see RFC 7111. The description of a .csv file and the separator behaviour are from Microsoft's help page on importing and exporting text files.

Verified on 2026-11-12 by the Statementizer Team.