CSV File
Definition
CSV stands for comma-separated values, described rather than invented by RFC 4180 in 2005. Each line is a record, fields are divided by a comma, and the first line is usually a header naming the columns. A field containing a comma, a double quote or a newline must be wrapped in double quotes, and a literal double quote inside such a field is written twice — so the value She said "yes", twice becomes a quoted field with doubled quote marks. The separator is not actually fixed: Excel on a machine with a French or German locale writes and expects semicolons, because those locales use the comma as a decimal point. Nothing in the file records which character set it uses, which is why the content type carries that information instead: text/csv; charset=utf-8.
Why It Matters
The famous complaint is that Excel mangles the data, and it is accurate. Open a CSV by double-clicking it and Excel applies its own guesses: a product code like 007312 loses its leading zeros and becomes 7312, a value like 3-10 becomes a date in March, and a long numeric identifier such as 1234567890123456 is stored as a float and comes back with the last digits replaced by zeros. None of that is in the file — it happens on import, and it is silent. Genes got renamed for the same reason, which is why the HGNC formally changed gene symbols like SEPT1 in 2020 rather than keep losing them to autocorrect. Importing through Data, then From Text/CSV, and setting the affected columns to Text avoids all of it.
How It Works
A CSV served with Content-Type: text/csv and no attachment disposition is displayed by most browsers as raw text in the window, which is often what you want for a small file someone is inspecting. Add Content-Disposition: attachment with a filename and it saves instead, ready for a spreadsheet. Line endings matter more than people expect: RFC 4180 specifies CRLF, some Unix tools emit bare LF, and old Mac software emitted bare CR, which certain parsers read as a single enormous line. Encoding is the other axis — a UTF-8 file with no byte order mark opens in Excel for Windows as mojibake, with names like Müller showing as Müller, while the same file with a UTF-8 BOM opens correctly. Writing the BOM is the pragmatic choice when Excel is the likely destination.
Real-World Example
A council publishes its monthly spending return at open-data.99helpers.site/spend-2026-03.csv, a 2.1 MB file of 18,000 rows. Because 99helpers serves it as text/csv, a journalist clicking the link sees the first lines in the browser and knows immediately whether the columns are what they expected, rather than downloading blind. A script elsewhere fetches the same URL each month with no parsing of a web page involved. When one month's export ships with semicolons by mistake, the team spots it in the browser preview within minutes and reuploads under the same name.
Common Mistakes
- ✕Double-clicking a CSV to open it in Excel — the import guesses types silently, and leading zeros, dates and long identifiers are damaged before you see the sheet
- ✕Writing UTF-8 without a byte order mark for a file destined for Excel on Windows — accented characters arrive as mojibake and every name in the sheet is wrong
- ✕Splitting lines on the comma with a simple string split — any quoted field containing a comma is torn in half, and the row count still looks plausible
- ✕Assuming the delimiter is always a comma — a colleague on a European locale exports semicolon-separated values that your parser reads as one giant column
Related Terms
Character Encoding
A character encoding is the rule that maps the bytes in a file to the characters a person reads. Get it wrong and nothing errors — the text simply comes out as the wrong characters.
Plain Text File
A plain text file holds characters and line breaks and nothing else — no fonts, no sizes, no embedded images. It is the format that survives everything, and the one that carries no clue about how to read its own bytes.
XLSX File
An XLSX is an Excel workbook stored as a ZIP archive of XML parts, one per worksheet, plus a shared table of every text string in the book. Browsers cannot open one, so publishing a spreadsheet means publishing a download.
MIME Type
A MIME type, also called a media type or content type, is the short label a server sends to say what kind of data a response contains — text/html, image/png, application/pdf. The browser decides what to do with the bytes based on that label, not on the file name.
Direct Link
A direct link points at a file's bytes rather than at a page about the file. Request it and you get the file itself, with its own Content-Type header and nothing wrapped around it.
Put a file online in seconds
Drop in a document, an image, a page or a whole static website and share the link — free, with no build step and no server to set up.
Host a file free →