The CSV (.csv) Format, Explained
iLoveConverter Team 4 min read
On this page
CSV is the tabular format of the internet. It has no schema, no types, no metadata, and almost everyone can open it. That is why it is still the standard interchange between databases, spreadsheets, data pipelines, and APIs. But “comma separated values” is misleading — the comma is just the default delimiter, and even then, quotes, newlines inside fields, different encodings, and locale-specific quirks make it trickier to get right than people expect.
The basics
A CSV is plain text. Rows are lines separated by line endings (typically \r\n or \n). Each row has fields separated by a delimiter (default comma, but tab, semicolon, pipe, or even | are common). Values that contain the delimiter, a quote, or a newline must be enclosed in double quotes. A literal double quote inside a quoted value is escaped by doubling it: "He said ""hello""".
A simple valid CSV:
name,email,score
Alice,[email protected],95
Bob,"bob, [email protected]",88
Row 3 shows the comma-inside-field quoting rule.
RFC 4180 — the closest thing to a standard
RFC 4180 (2005) attempts to formalize CSV, but many tools deviate from it:
- Delimiter — RFC says comma, but Excel in European locales defaults to semicolon.
- Encoding — RFC says ASCII; most modern tools produce UTF-8, sometimes with a BOM.
- Header row — RFC says the first row may be column names, but this is optional.
- Line endings — RFC says CRLF; Unix tools often use LF only.
The lack of strict enforcement is CSV’s defining feature — it is flexible because nothing standardizes it.
Dialects
Python’s csv module formalizes common CSV “dialects” with configurable parameters:
| Parameter | Default | Notes |
|---|---|---|
| delimiter | , | Field separator |
| quotechar | " | Quote character |
| escapechar | None | Alternative escape |
| doublequote | True | How to escape quotes |
| lineterminator | \r\n | Row separator |
| skipinitialspace | False | Ignore spaces after delimiter |
When parsing CSV from unknown sources, first sniff the dialect:
import csv
with open("unknown.csv") as f:
dialect = csv.Sniffer().sniff(f.read(2048))
f.seek(0)
reader = csv.reader(f, dialect)
Encoding: UTF-8 vs UTF-8 BOM vs Latin-1
- UTF-8 — the modern standard. No BOM.
- UTF-8 with BOM (byte order mark
EF BB BF) — Excel on Windows sometimes adds this; tools that do not strip the BOM get a garbage first field. - Windows-1252/Latin-1 — many legacy CSVs from Excel in non-English locales use this, replacing
€as\x80and smart quotes as\x93 \x94.
Always explicitly specify encoding when opening CSV. Do not rely on platform defaults.
Converting CSV
# CSV to JSON (jq):
jq -R -s 'split("\n") | map(split(",")) | .[0] as $header | .[1:] | map({($header[0]): .[0], ($header[1]): .[1]})' input.csv
# CSV to Parquet (Python pandas):
python3 -c "import pandas as pd; df = pd.read_csv('input.csv'); df.to_parquet('output.parquet')"
# CSV to Excel:
python3 -c "import pandas as pd; df = pd.read_csv('input.csv'); df.to_excel('output.xlsx', index=False)"
Common problems
- Numbers stored as text — CSV has no type system. Excel may interpret
00123as text and0123as the number 123. Add a leading apostrophe or use a schema. - Excel auto-formats dates — any field matching a date pattern may be silently converted. Wrap in quotes or use a CSV import wizard.
- Semicolon delimiter confusion — Excel in some locales defaults to
;not,. Python’scsvmodule will not detect this automatically; useSniffer. - Trailing newlines — some files end with extra blank rows;
csv.readermay include empty rows; filter them out.
FAQ
Is there an official CSV standard?
RFC 4180 is the closest thing, but it is more descriptive than prescriptive. No one enforces it. In practice, “CSV” means “whatever your spreadsheet tooling produced.”
What’s the difference between CSV and TSV?
Delimiter only. CSV uses comma (default), TSV uses tab. Both have the same quoting rules. Use TSV when your data may contain commas.
Why do some CSVs fail to open in Excel?
Encoding mismatch (UTF-8 BOM missing, or Latin-1 with special chars), delimiter mismatch (semicolon vs comma), or too many rows (pre-2007 Excel capped at 65,536).
Can CSV hold complex data?
No. One table, flat rows, no nested structures, no types, no schemas. If you need hierarchy, types, or validation, use JSON or Parquet instead. CSV is for exchange, not storage.
Try it yourself — free, right in your browser
Everything mentioned in this guide runs locally on this site: no upload, no watermark, no sign-up.
Format deep-dives: CSV (.csv) , JSON (.json) , XLSX (.xlsx) , TSV (.tsv.tab)