Data · 25 tools · nothing uploads

Sample rows from a CSV

Take a sample of a CSV's data rows: the first N (head), N picked at random but kept in their original order (random), or the whole file shuffled and cut to N (shuffle). Seedable for a repeatable sample. Runs entirely on your device.

Input

Options

live

Sample rows from a CSV offers three modes. Head takes the first n rows; random picks n at random while keeping order; shuffle scrambles every row before cutting to n. A blank seed draws a value from the clock. Typed text hashes deterministically for a repeatable sample. Asking for more rows than the file holds returns every row.

Questions

What do head, random and shuffle each do?

head keeps the first n rows in order; random picks n rows at random but keeps them in their original order; shuffle scrambles every row first, then cuts to n.

What does the seed do?

A typed seed hashes deterministically with FNV-1a into the random generator, so the same seed and mode always give the same sample. Blank seed uses the clock, so each run differs.

What if n is bigger than the file?

The tool returns every row it has, capped at the file's row count.

Does head need a seed?

No, head always takes the first n rows regardless of seed.

What if n is not a whole number of 1 or more?

It is refused with a message saying n must be a whole number of 1 or more.

Related Data tools

1→1Reorder / insert CSV columnsReorder (and drop) a CSV's columns by name, and optionally insert one new column with a constant value at a given position. Quote-aware. A record with a quoted field containing a literal newline stays one record.Takes one file1→1Map CSV column namesRename a CSV's header to a new schema ("old=new" pairs), and optionally drop every column that isn't named in the mapping. Column order and data are otherwise untouched. Quote-aware. A record with a quoted field containing a literal newline stays one record.Takes one file1→1Change CSV separatorRe-delimit a CSV (comma, semicolon, tab or pipe), auto-detecting the current separator when not told what it is. Quote-aware. A record with a quoted field containing a literal newline (including in the header) stays one record.Takes one file1→1Transpose CSVSwap a CSV's rows and columns. Column 1 becomes row 1, and so on. A ragged row (fewer cells than the widest row) is padded with empty cells rather than refused. Quote-aware. A record with a quoted field containing a literal newline stays one record, not two.Takes one file1→1Split CSV into partsCut a CSV into several smaller files of N data rows each, repeating the header in every part. Quote-aware: a record with a quoted field containing a literal newline stays one record.Takes one filen→1Merge CSV filesConcatenate several CSVs with the same header into one file, in the order given. Quote-aware. A record with a quoted field containing a literal newline stays one record.Combines the files you drop1→1Remove duplicate CSV rowsStrip repeated rows from a CSV. Compares whole records, not physical lines, so a quoted field containing a newline is one record and stays one record.Takes one file1→1Find incomplete CSV recordsReport every record whose cell count doesn't match the header: too few cells (a truncated record) or too many (an unescaped comma). Read-only: nothing is changed. Quote-aware, so a record with a quoted field containing a literal newline still counts as one record with the right cell count.Takes one file