tsvkit.org
TSV Toolkit
Sample data Say hi →

Random Sample of TSV Rows

count or percentage · seeded and repeatable · header kept

Pull a genuine random sample out of a large file — for a QA pass, a manual review, a demo dataset, or a statistical estimate. Every row has an equal chance of selection, which is what makes it different from taking the first N rows: an export is almost always ordered by something, so its head is a biased slice. Supply a seed and the same sample comes back on every run, which is what makes a review reproducible.

sample
Drop a .tsv file here, or
ready

How to use

  1. Paste or drop the file.
  2. Choose a count or a percentage. A count is right when a person has to review each row; a percentage is right when you're estimating something about the whole.
  3. Type a seed — any word — if you'll need this exact sample again. The status line confirms whether the run is repeatable.
  4. Keep original row order on so the sample reads like the source file; untick it if you want the rows shuffled too.

Why the seed matters

With a seed, the sample is a deterministic function of that seed and the row count — the same file and the same seed always produce the same rows. That's what lets you say "I reviewed sample audit-july" and have someone else reproduce it exactly, or re-run the same sample after fixing a bug to check the fix. Without a seed, every run is different, which is fine for a quick look and useless for anything you need to defend.

Changing the seed gives you an independent sample from the same file — useful for a second reviewer, or for checking that a conclusion isn't an artefact of one draw. Note that the seed doesn't guarantee stability if the file changes: add a row and the shuffle changes for everything.

Choosing a sample size

For manual review, the number of rows a person will actually read is the constraint — usually 50 to a few hundred. For estimating a proportion (what share of rows have a problem), the useful rule of thumb is that the margin of error is roughly 1/√n: 100 rows gives you about ±10 points, 400 gives ±5, 1,000 gives ±3. Sampling 1% of a 10-million-row file gives you 100,000 rows, which is far more precision than any question needs and more than you can review.

If the thing you're looking for is rare, plain random sampling will miss it — 200 rows from a file with a 0.1% error rate will probably contain no errors at all. Filter to the suspicious subset first with filter rows and sample that.

FAQ

Is the randomness good enough for statistics?

The shuffle is a Fisher-Yates over a seeded PRNG (mulberry32), which is uniform and unbiased — fine for sampling, QA, and estimation. It is not cryptographically secure, so don't use it to draw lottery winners or generate secrets.

Can I sample proportionally per group — stratified?

Not in one step. Split by column value to get one file per group, sample each with the same seed, then merge the results. That's a genuine stratified sample and takes about a minute.

Will the same seed give the same sample tomorrow?

Yes, as long as the input file is byte-identical. The algorithm is fixed and there's no time or machine input to it.

What's the shell equivalent?

(head -1 f.tsv; tail -n +2 f.tsv | shuf -n 100) on GNU coreutils, with --random-source for repeatability. macOS ships gshuf via coreutils or you can use sort -R, which is slower and less uniform.

Privacy

100% client-side. No upload. See the privacy policy.