Updated 2026-10-21
CSV File Example: Three Sample Files and What Each One Proves
A CSV file example is three lines of plain text: a header naming the columns, then one line per record with commas between the fields. That is the whole format. The interesting part starts when a value contains a comma, a quote or a line break, because then the file must use quoting rules that a text editor shows and a spreadsheet hides.
Quick answer
Copy any of the three blocks below into a file, save it with a .csv extension, and you have a working CSV. The first is the plain case with no special characters. The second contains a comma and a double quote inside values, so it shows the escaping rule. The third holds a date, a decimal and an identifier with leading zeros, which is where automatic type detection quietly changes your data. Each block is followed by its exact byte count, measured on 2026-10-21, so you can confirm that your copy matches.
Example 1: the plain case
name,email,phone
Ann Lee,ann@example.com,+1 555 0100
Bob Ray,bob@example.com,+1 555 0111Saved with CRLF line endings this file is 92 bytes: three records, three line terminators, no quoting at all. RFC 4180 section 2 item 1 describes exactly this form, each record on its own line delimited by CRLF, and item 3 allows the first line to name the fields. Nothing here needs escaping, which is why it is the right shape to start from when you are building a file by hand.
One thing to notice: the phone numbers contain spaces and a plus sign, and they are not quoted. That is legal, because spaces are ordinary characters inside a field. RFC 4180 item 4 says so directly, spaces are considered part of a field and should not be ignored, which is also why a stray space before a comma becomes part of the previous value rather than disappearing.
Example 2: commas and quotes inside values
name,note
Ann,"Seattle, WA"
Bob,"He said ""ok"""52 bytes with CRLF endings, still three records and three terminators, and the second field of each data row is wrapped in quotes. The first row needs them because the value contains a comma. The second row needs them twice over: the value contains a comma and a pair of double quotes, and RFC 4180 section 2 item 7 requires an inner double quote to be doubled. A reader removes the outer quotes and collapses the doubled pair, so the value arrives as He said "ok".
This is the sample worth keeping next to you when a file imports with columns shifted one to the right. It shows what correct escaping looks like, so a missing or single quote stands out. Our guide to quotes in CSV files covers the failure modes in detail.
Example 3: dates, decimals and leading zeros
order_id,date,total
1001,2026-01-05,19.99
1002,2026-01-06,5.0066 bytes with CRLF endings. Every value here is text in the file, including the total, and the file itself carries no type information: RFC 4180 defines records and fields, and nothing about numbers or dates. The interpretation happens in the reader, which is where a date written 2026-01-05 can be displayed as 1/5/2026 and a total of 5.00 can become 5.
Identifiers suffer the same treatment and lose more. We tested a row containing 001, 007and a 16-digit number on 2026-10-21. Read with pandas' default type inference the values came back as 1, 7 and 1234567890123456; read with dtype=str they stayed 001, 007 and 1234567890123456. The file did not change. The reader did. Our guide to keeping leading zeros has the fixes for Excel specifically.
What the bytes behind these samples look like
If you are checking a file rather than writing one, the first few bytes answer most questions. A plain ASCII CSV starts with the first character of its header, so name,email begins 6e 61 6d 65. Two other openings mean something else is going on:
ef bb bfis a UTF-8 byte order mark. Legal text, but some readers keep it as part of the first column name, so the header arrives as\ufeffnameand any lookup by column name fails.50 4b 03 04is a zip archive, which is what a renamed .xlsx looks like. It is not a CSV no matter what the extension says.3c 21 44 4f 43 54 59 50spells<!DOCTYP, the start of an HTML page saved under a .csv name, which is what a download from a login screen usually produces.
Line endings matter for the same reason. CRLF is 0d 0a and RFC 4180 asks for it, but files written by Unix tools use a single 0a and old Mac exports used a single 0d. All three parse in a modern reader; only the byte count differs, which is why our samples specify theirs. The encoding guide covers the code pages behind non-ASCII text.
Building your own example in four rules
- One record per line, and the same number of fields on every line.
- No comma after the last field. A trailing comma adds an empty column that some readers name
Unnamed. - Quote any value containing a comma, a double quote or a line break, and double the quotes inside it.
- No blank lines between records. Readers disagree about whether a blank line is a record, so the row numbers in your script and in your spreadsheet drift apart.
Save as UTF-8 without a byte order mark unless you have a specific reason, and test the file by opening it in a text editor before you open it in a spreadsheet. The editor shows the truth; the spreadsheet shows an interpretation. If you want to see the interpretation side by side with the columns it detected, paste the sample into the CSV analyzer and compare the preview with the three lines you wrote.
Turning an example into another format
The same three records convert cleanly in either direction. The JSON to CSV converter produces a file with a header built from the object keys, which is the shape example 1 already has. Going the other way, a JSON array of objects is the usual target when an API wants the data, and the CSV versus TSV comparison explains when a tab is the safer separator than a comma.
Sources
- IETF, RFC 4180: Common Format and MIME Type for CSV Files, section 2, items 1, 3, 4, 6 and 7 (CRLF-terminated records; optional header line whose presence must be signalled outside the file; spaces are part of a field; fields containing line breaks, double quotes or commas should be quoted; an inner double quote is escaped by doubling it). Section 2 also says nothing about numeric, date or size limits.
- Microsoft Support, "Import or export text (.txt or .csv) files" (up to 1,048,576 rows and 16,384 columns per import or export).
- Microsoft Support, "Keeping leading zeros and large numbers" (Excel removes leading zeros and converts long digit strings to scientific notation when a value is interpreted as a number).
- Our own measurements, 2026-10-21, Python 3.13.5 with pandas 2.3.3, scripts and output kept under
seo_geo_ops/nc_measure_20261021/: example 1 is 92 bytes with three CRLF terminators, example 2 is 52 bytes and parses toHe said "ok", example 3 is 66 bytes; the values001and007came back as1and7under default type inference and unchanged underdtype=str, andcsv.field_size_limit()returned 131,072 characters.
Related reading
Try the samples without installing anything
Paste any of the three blocks into the analyzer to see how it reads them: column count, detected types and the first rows as a table. Parsing happens in the browser, and the file is not uploaded for that step.
Frequently asked questions
What does a CSV file look like?
It looks like plain text and nothing else. The first line usually names the columns, every following line is one record, and a comma separates the fields inside a record. RFC 4180 section 2 item 1 says each record sits on its own line, terminated by CRLF. Open a real one in Notepad or TextEdit and you see exactly that: three lines of comma-separated words, no formatting, no colours, no hidden sheet.
Does a CSV file need a header row?
No, the header is optional and the format has no flag that marks it as a header. RFC 4180 section 2 item 3 calls it an optional header line appearing as the first line of the file, and adds that the presence or absence of that line should be indicated through a parameter outside the file. In practice almost every export includes one, and every tool we know assumes the first row is a header unless you tell it otherwise. Our samples all include one, because without it a reader has to fall back to column numbers.
How do you put a comma inside a CSV value?
Wrap the whole value in double quotes. RFC 4180 section 2 item 6 says fields containing line breaks, double quotes and commas should be enclosed in double-quotes, and item 7 says a double quote that appears inside such a field is escaped by writing it twice. A note reading He said ok with ok in quotes is therefore stored as quote, He said, space, double quote, double quote, ok, double quote, double quote, quote. A reader removes the outer pair and turns each doubled pair back into a single quote, so the value arrives intact.
Why does the same CSV look different in a spreadsheet and a text editor?
Because the spreadsheet interprets and the editor only displays. In a text editor you see the separator characters, the quote characters and the line endings, which is what you need when something is wrong. In a spreadsheet the file is parsed first, so quotes disappear, commas inside quotes become ordinary characters, and a value of 001 becomes the number 1. Our sample with three columns showed exactly that: read as text the value stayed 001, read with default type inference it arrived as 1.
Is a CSV the same as a TSV?
No. Both are plain text with one record per line, and the only difference is the separator character: a comma in CSV, a tab in TSV. Pasting tab-separated data into a file named .csv is a common reason a file opens as a single column. If your values contain commas more often than tabs, TSV avoids quoting altogether, which is why log and bioinformatics exports tend to use it.
How many rows or columns can the example files hold?
The format itself sets no limit; RFC 4180 defines records, fields and quoting, and nothing about size. The limits you meet in practice come from the reader. Microsoft's import and export article states that you can import or export up to 1,048,576 rows and 16,384 columns in Excel, and Python's csv module refuses a single field past 131,072 characters unless the limit is raised. A CSV of any size is valid text; whether your tool will open it is a separate question.
Related reading
CSV Fundamentals — other guides that pair well with this one.
- How to Open a CSV File in Windows (Notepad, Excel, PowerShell)
- How to Open a CSV File on Android (Google Sheets, Text Editors, File Managers)
- Convert CSV to Excel Without Excel
- Convert Excel to CSV Free Online
Browse all guides in the NoCodeCSV blog.