Data Sampler

Cut a long CSV or list down to a readable number of rows, without losing their original order.

Runs on your deviceDataWorkingNo account needed

What this tool does

Data Sampler reduces a pasted table to a manageable slice. Four modes decide which rows survive: the first N, the last N, N drawn at random, or every Nth row for an even spread from the top of the file to the bottom. Whichever you pick, the rows come out in the order they went in, and a CSV header row is lifted off before sampling and put back on top of the result afterwards.

Random mode uses reservoir sampling, so every data row carries exactly the same chance of being kept regardless of where it sits in the file, no row can be drawn twice, and the selection is made in one pass rather than by shuffling a copy of everything. Leave the seed box empty and each run gives a different draw; type any word into it and the same input returns the same rows every time, which is what makes a sampled test fixture worth committing to a repository.

A few limits are worth knowing before you paste a real file. Everything runs in this browser tab and nothing is transmitted, but this is a text box rather than a file picker, so the input arrives through the clipboard and the whole of it has to fit in the tab's memory — a few megabytes of CSV is comfortable, a multi-gigabyte export is the wrong job for it. In CSV mode the output is also written out fresh rather than copied line for line, which normalises quoting, separates records with CRLF and pads short rows to the width of the widest row. Sampling is uniform over rows only: there is no grouping by column value, so a stratified sample that keeps a fixed share of each category has to be built somewhere else.

How to use it

  1. Paste the data. The rows go straight into the input box; Load sample fills it with a small CSV if you want to see the expected shape first.
  2. Say what the input is. CSV rows parses quoting and can detect the delimiter for you. Plain lines treats every line as one opaque record and leaves it alone.
  3. Choose how to sample. First rows, Last rows, Random rows or Every Nth row. Every Nth begins at the first data row and steps through to the end of the file.
  4. Set the size. A number of rows, or a percentage of them, for the first three modes. Ask for more rows than the file holds and you get the whole file back.
  5. Deal with the header and delimiters. First row is a header keeps that line out of the draw and back on top of the output; the box belongs to CSV rows only, so under Plain lines the first line is sampled like any other. The output delimiter can differ from the input one.

Processing & privacy

Runs on your device. Your file is processed directly in this browser.

Common use cases

Previewing an unfamiliar export

Take the first hundred rows to see the columns and the shape of the values before writing an import script against the full file.

Building a repeatable test fixture

Sample rows at random with a seed, so the fixture stays small, spreads across the whole file, and comes out identical when somebody regenerates it.

Reading the end of a long export

Last rows shows the most recent entries without scrolling through a hundred thousand lines to reach the bottom of them.

Thinning a time-ordered series

Every Nth row keeps the spread of a whole year while cutting the row count down to something a quick chart or a sanity check can use.

Questions

Do the rows I paste leave my browser?
No. Parsing and sampling both happen in this browser tab, so the rows you paste are not transmitted or stored, and the tool still works with the network switched off.
Is the random sample genuinely uniform?
Yes. Reservoir sampling gives every data row the same probability of being kept and never picks one twice. The chosen rows are then sorted back into their original file order before being written out.
What does the random seed do?
It makes the draw repeatable: the same seed, input and count return the same rows. Leave it blank and every run produces a different sample.
Does the header count towards the number of rows?
No. With First row is a header ticked, the header is removed before sampling and restored afterwards, so asking for 100 rows gives you 100 data rows plus that header line.
Will the output match my original lines exactly?
In CSV mode, not quite — the rows are re-serialised, so quoting is normalised, records end with CRLF, and ragged rows are padded with empty fields to match the widest row. Plain lines keeps the text of each line exactly as you pasted it, but it still drops a leading byte order mark, rewrites CR and CRLF line endings as plain LF, and swallows the empty line that a trailing newline leaves behind.
How large an input can it handle?
The whole text has to arrive through the clipboard and sit in the tab's memory, so a few megabytes is fine and much beyond that will make the tab struggle. Break the file up with CSV Split first if it is larger than the box can take.
Can I keep a fixed share of each category?
No. The draw is uniform across rows with no awareness of column values, so a stratified sample needs a different approach. Column Extractor narrows a file by column, and Remove Duplicates thins it by repeated values.

Related tools

  • JSON to CSV — Flatten a JSON array into a CSV table.
  • CSV to JSON — Turn a CSV file into structured JSON.
  • CSV Viewer — Open and browse a large CSV without a spreadsheet app.
  • CSV to Excel — Convert CSV files into an XLSX workbook.
  • Excel to CSV — Export spreadsheet sheets to CSV.
  • CSV Merge — Combine multiple CSV files with matching columns.