Slice TSV Rows
Cut a file down to the rows you want, with the header carried along so the result is still a valid TSV. head -20 on a data file gives you 20 lines including the header, which is not the same as 20 records — this counts data rows and keeps the header separately. Useful for making a small test fixture out of a large export, or pulling out the rows around a problem line the validator pointed at.
How to use
- Paste or drop the file. Row numbering is over data rows, so from 1 means the first record, not the header.
- Pick a mode. First N and last N use the N field; range uses From and To; every Nth uses N as the step.
- Leave To blank in range mode to run to the end of the file.
- Copy or download. The status line reports how many of how many rows survived.
What each mode is for
First N makes a test fixture or a sample to eyeball. Last N checks the tail of an export — the place truncated files and stray summary rows show up. Range is the one to use when a loader failed at row 4,812: slice 4,800–4,820 and look at what's there. Every Nth thins a large series down for plotting while keeping its shape; unlike random sampling, it's evenly spaced and completely deterministic, which is what you want for a time series and not what you want for a statistical sample.
FAQ
Is row 1 the header or the first record?
The first record. The header is held aside and re-attached to whatever you slice, so a range of 1–10 gives eleven lines: the header plus ten records. Tick no header row if your file has none, and then row 1 is the first line of the file.
How do I get a random subset instead?
Random sample — and prefer it whenever the subset needs to be representative. The first N rows of an export are usually sorted by something, which makes them a biased sample.
Can it split the file into all its chunks at once?
That's split a TSV file — every N rows, into N parts, or one file per column value, with a zip download.
What's the shell version?
(head -1 f.tsv; tail -n +2 f.tsv | head -20) for the first 20 records, and awk 'NR==1 || (NR>=4801 && NR<=4821)' for a range including the header.
Privacy
100% client-side. No upload. See the privacy policy.