CSV is short for comma-separated values and represents a text format where each line is a set of values delimited by comma.
CSV is a text-based file format where limitations on characters which could be stored in it depend on the specific CSV reader and writer implementations.
CSV is implementation specific and various readers and writers can have some compatibility problems.
The most popular and generic CSV file format adheres to the following rules:
Below is an example of CSV file with CRLF, comma and double quotes used inside values.
Name, Job Title, Address CRLF
John Doe, Designer, "Third Avenue CRLF
325" CRLF
Edward Johns, Tester, "Pike ""Street"", 200" CRLF
As you can see above "Third Avenue CRLF
325" value has a line break inside it. Because the value is enclosed in double quotes it will be correctly interpreted by most CSV parsers. Same goes about "Pike ""Street"", 200" value. It uses double quotations to enclose the value and all double quotations inside the value are preceded by double quotation prefix. It will be parsed correctly as a single value and comma inside it will not be parsed as value separator.
There are technically not limitations on the size and number of lines or fields inside the CSV file. In certain cases, limits could be set by specific writers, parsers, and computer memory limits. If necessary, CSV file could be split into multiple ones.
Frequently CSV file first line is reserved to be used to store column names for corresponding values below. Having column names in the file simplifies understanding what is inside the file and how to correctly process it.
Formal specification for CSV file format is available as RFC 4180 specification. It is used by many CSV readers and writers and is a great place to start when writing a code which should work with a CSV file.
CSV Quick Info | |
---|---|
Comma Separaed Values | |
MIME Type | |
text/csv | |
Opens with | |
Microsoft Excel | |
Apple Numbers | |
Google Sheets | |
Microsoft Office Online |