A CSV generator produces sample spreadsheet data for testing imports, exports and data pipelines. Pick from thirty-three realistic field types, choose a delimiter, and download a file with up to 5,000 rows. The options are the ones that actually break CSV importers: quoting, delimiters, Windows line endings and the UTF-8 byte order mark Excel needs.
CSV has a standard — RFC 4180 — and almost nobody follows it exactly. That is why a sample file with the right awkward properties is more useful than a clean one.
How to use it
- Tick the fields for your columns.
- Pick a delimiter: comma (CSV), tab (TSV), semicolon or pipe.
- Toggle the header row, quote-every-field, CRLF line endings and the UTF-8 BOM to match — or deliberately mismatch — what your importer expects.
- Set the row count (up to 5,000) and download the file.
What you can control
- Comma, tab, semicolon and pipe delimiters.
- RFC 4180 quoting: fields containing the delimiter, a quote or a line break are quoted, with embedded quotes doubled — or quote every field.
- LF or CRLF line endings.
- An optional UTF-8 byte order mark for Excel.
- An optional header row.
- The same thirty-three field types as the JSON and SQL generators, with one coherent person per row.
The CSV properties that break importers
| Property | What goes wrong |
|---|---|
| UTF-8 BOM | Without it, Excel on Windows shows Zoë instead of Zoë. With it, a naive parser reads the first header as \ufeffid and cannot find the id column. |
| CRLF line endings | Files saved on Windows end each line with \r\n. A parser splitting on \n leaves a stray \r in the last field of every row. |
| Quoted delimiters | "Acme, Inc." is one field. Splitting on commas makes it two and shifts every column after it. |
| Embedded quotes | "He said ""hi""" is valid RFC 4180. Hand-written parsers rarely handle doubled quotes. |
| Semicolons | European Excel exports use ;. An importer that hard-codes , reads every row as a single column. |
Generate one file with each property turned on and run them all through your import. The ones that fail are your bug list.
Using it in a test
import csv
FIXTURE = "fixtures/users_bom_crlf.csv"
def test_import_handles_bom_and_crlf(client):
with open(FIXTURE, newline="", encoding="utf-8-sig") as f:
expected = list(csv.DictReader(f))
with open(FIXTURE, "rb") as f:
response = client.post("/import", files={"file": f})
assert response.json()["imported"] == len(expected)
assert response.json()["first"]["id"] == expected[0]["id"] # not "\ufeffid"
encoding="utf-8-sig" strips the BOM on the Python side; your importer has to do the same.
What this is not
This produces well-formed CSV. To test how your importer handles broken files — truncated rows, unbalanced quotes, mixed encodings — use the malformed data generator.