Download a large CSV sample for testing

How to get or generate a big CSV sample for testing, what CSV-to-TSV conversion really changes, and how to check the file stays usable after sharing.

A large CSV sample is useful for checking whether an importer, parser, spreadsheet, database load job or conversion script behaves correctly when the data is big and messy. This guide covers when a downloaded sample is enough and when generating your own works better. It also explains what converting between CSV and TSV actually changes, and how to confirm the file still means the same thing after it is copied, shared or opened in another tool.

Scope note: no specific downloadable datasets were evaluated for this article, and no file sizes, load times or tool benchmarks were measured. The guidance below rests on general, verifiable behavior of the CSV and TSV formats and common tools. Where a claim depends on a particular application or environment, test it there before relying on it.

What counts as a large CSV sample

There is no fixed size at which a CSV becomes large. A file is large for testing purposes when it is big enough to expose the limit you care about. That could be a spreadsheet row cap, a memory ceiling in a script that loads the whole file at once, an upload size limit, or a timeout in a web form. For example, Microsoft Excel worksheets are documented as holding at most 1,048,576 rows. A file just past that limit tests truncation handling, while a file far beyond it tests streaming. Pick the target size from the constraint you are probing, not from a round number.

Is a downloaded sample suitable for your test?

Recommendation: use a downloaded public sample when you need realistic structure, such as real-world column names, uneven value lengths and genuine missing data. Generate your own file when you need control over size, reproducibility and edge cases. The decisive tradeoff is that a downloaded file shows you what real data looks like but rarely contains the specific awkward cases your parser must survive, while a generated file contains exactly those cases but can miss quirks you did not think to include.

Need | Downloaded sample | Generated sample
Realistic content and distributions | Usually better | Only as realistic as your generator
Exact row count or file size | Fixed by the publisher | Set by you
Deliberate edge cases (embedded commas, quotes, line breaks) | Present only by chance | Included on purpose
Reproducibility across test runs | Stable if the source does not change | Stable with a fixed random seed
Licensing and personal data questions | Must be checked per source | Avoided if values are synthetic

Before using any downloaded file, read its license and check whether it contains personal or sensitive information. A dataset described as open or anonymized has not necessarily been reviewed for your use case. Its marketing or page design says nothing reliable about how the data was collected or retained.

A small plain-text file is preferable to a large one when the goal is to show a bug to someone else, document an expected format, or review a few records by eye. Large files are for load and robustness testing. Short, readable samples are for communication.

Generating a large CSV with known edge cases

The script below writes a CSV with a header row and a configurable number of records. It uses a fixed random seed so each run produces the same file. It deliberately mixes in values that commonly break naive parsers: an embedded comma, embedded double quotes, a line break inside a field, a non-ASCII character, a value with a leading zero and an empty field. The row count is a parameter to adjust, not a recommendation.

import csv
import random
import string

ROWS = 1_000_000  # adjust to the limit you want to test
random.seed(42)    # fixed seed keeps the file reproducible

tricky = [
    'plain value',
    'comma, inside',
    'quote "inside"',
    'line\nbreak inside',
    'café',
    '00123',
    '',
]

with open('sample_large.csv', 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['id', 'name', 'amount', 'note'])
    for i in range(1, ROWS + 1):
        name = ''.join(random.choices(string.ascii_letters, k=8))
        amount = f'{random.uniform(0, 10000):.2f}'
        writer.writerow([i, name, amount, random.choice(tricky)])

Python's csv writer quotes fields that need it and doubles any quote characters inside them. That follows the convention described in RFC 4180, the most widely cited description of CSV. Not every tool follows that document, which is part of what a test file like this is meant to reveal.

What CSV-to-TSV conversion actually changes

Converting CSV to TSV changes the stored characters that separate fields. Commas become tab characters. The values themselves should not change, but a few related details often do.

  • Delimiter: the field separator changes from a comma to a tab. Commas inside values no longer need quoting, but tabs inside values do.
  • Quoting: CSV relies on double quotes to protect commas, quotes and line breaks inside fields. Some TSV readers support the same quoting. Others treat TSV as a format with no quoting at all and expect fields never to contain tabs or line breaks. A converter that emits quoted TSV can produce a file that one tool reads correctly and another misreads.
  • Line endings: a converter may write LF or CRLF line endings regardless of what the source used. Most parsers accept both, but byte-for-byte comparisons and some legacy systems do not.
  • Encoding and byte order mark: re-saving can change the text encoding or add or remove a UTF-8 byte order mark. That affects whether non-ASCII characters such as accented letters display correctly in the destination.

It also helps to separate stored changes from presentation. A spreadsheet that opens a CSV may display 00123 as 123, show long digit strings in scientific notation, or interpret a value like 3-4 as a date. Those are display interpretations at first. They become stored changes if the file is saved back from the spreadsheet. For testing, compare the raw file on disk, not what an application shows on screen.

The following conversion reads CSV with a real parser rather than replacing commas with tabs. A plain find-and-replace would corrupt any field that contains a comma or a quoted line break.

import csv

with open('sample_large.csv', newline='', encoding='utf-8') as src:
    with open('sample_large.tsv', 'w', newline='', encoding='utf-8') as dst:
        reader = csv.reader(src)
        writer = csv.writer(dst, delimiter='\t', lineterminator='\n')
        for row in reader:
            writer.writerow(row)

Because this keeps quoting, the TSV output will contain quoted fields wherever the source had line breaks or quote characters. If your destination expects unquoted TSV, those values must be cleaned or rejected before conversion. There is no lossless way to put a raw tab or line break into a field of a format that forbids them.

Checking that meaning survived the conversion

The reliable test is a round trip: parse both files and compare them record by record. The script below streams both files, so it does not need to hold a large file in memory, and it stops at the first difference.

import csv
from itertools import zip_longest

with open('sample_large.csv', newline='', encoding='utf-8') as a:
    with open('sample_large.tsv', newline='', encoding='utf-8') as b:
        pairs = zip_longest(csv.reader(a), csv.reader(b, delimiter='\t'))
        for n, (left, right) in enumerate(pairs, start=1):
            if left != right:
                print(f'Mismatch at record {n}')
                break
        else:
            print('All records match')

Quick shell checks can mislead with files like this. A line-counting command such as wc -l counts newline characters, not records, so it overcounts whenever fields contain embedded line breaks. Previewing the first few lines with head can likewise cut a record in half. Use a CSV-aware parser whenever an exact record count matters.

Will the file stay usable after copying or sharing?

Several common handling steps can quietly alter a test file or make it hard to use:

  • Copy and paste: pasting tab-separated text into many spreadsheets splits it into columns automatically, which makes TSV convenient for quick transfers. Pasting comma-separated text usually lands in a single column unless an import step is used. Pasting through a chat or email client can also change line endings or strip tabs. Share large samples as file attachments or archives rather than pasted text.
  • Opening and re-saving: as noted above, saving from a spreadsheet can rewrite leading zeros, long numbers and date-like strings. Keep a pristine copy of the test file and treat any re-saved version as a different file.
  • Compression and transfer: compressing a large text file before sharing preserves its exact bytes and is generally safer than uploading through a tool that may preview or re-encode it. Whether a particular upload service alters files has to be checked for that service.
  • Search and editing: text search across the file will not find a value that is split by an embedded line break, and some editors become slow or refuse to open very large files. Keep a small companion sample for anything a person needs to inspect by hand.
  • Accessibility: a raw CSV or TSV read aloud by a screen reader is typically a continuous stream of values and separators with no column context. If people relying on assistive technology need to review the sample, present a short excerpt as a properly marked-up table with header cells, or describe the columns in plain text alongside the file. No specific screen reader was tested for this article, so confirm behavior with the assistive technology your readers use.

In short, a plain-text equivalent is needed whenever a person, rather than a program, is the consumer. A documented column list plus a handful of example records serves that purpose better than the full file.

Quick checklist for a useful large test file

  • Size chosen to exceed the specific limit being tested
  • Header row with stable, documented column names
  • Fields with embedded commas, quotes and line breaks
  • Non-ASCII characters and a declared encoding, normally UTF-8
  • Values a spreadsheet may reinterpret: leading zeros, long digit strings, date-like text
  • Empty fields and, if relevant, rows with missing trailing fields
  • A fixed generation seed or a recorded source and license for downloaded data
  • A round-trip comparison after any CSV-to-TSV conversion
  • A small, human-readable excerpt kept alongside the full file

Gaps to be aware of

This overview does not name or rate specific sample-file sources, and it does not report measured file sizes, parse speeds or memory use, because none were tested. Behavior described for spreadsheets, TSV readers, upload services and screen readers is general. Individual applications and versions differ, so the scripts above are best treated as a starting point for checks run in your own environment.