In short: RowSlice’s CSV sampler makes a small CSV out of a big one. It takes the rows from the start of the file, one row in every so many, a fixed number of rows drawn at random, or a share of them, and writes them to yourfile-sample.csv with the header row on top. It runs in your browser, so the file is never uploaded, and every row is copied as the text it was written in, in the order it was in the file.
This is not the sample CSV generator. This tool needs a file from you, and every row it writes came out of that file — your columns, your values, your data. The sample CSV file generator takes no file at all: it invents customers, orders, employees and products that never existed, for when you need test data that belongs to nobody. If you came looking for a file to download without having one to start from, that is the page you want.
A sample is for the jobs where the whole file is in the way: checking how the date column is written before you trust it, trying a new script on something small enough to read by eye, or loading a staging system with a few thousand real rows instead of every row you have. In each of those the rest of the file costs time and answers nothing. When reading some rows is the whole of the job, you may not need a file at all — the CSV viewer opens the original, pages through it 100 rows at a time and writes nothing.
How to Take a Sample from a CSV
- Choose or drag in your CSV file and check the preview of the first rows.
- Pick which rows to take: Rows from the start, One row in every so many, Rows drawn at random, or A share of the rows.
- Type the number that goes with it — how many rows, how often, or what percentage of them.
- Press Take the Sample and download
yourfile-sample.csv. The result says how many rows came out and, in the three modes that read to the end, how many rows the file holds.
If your file has no header row, untick First row is a header under Advanced Options. The first line is then treated as data, so it can be picked for the sample like any other row instead of being copied to the top of the result.
The Four Ways to Sample
| Sample type | What you get | When to use it |
|---|---|---|
| Rows from the start | The first rows of the file, in the order they are in it. The read stops as soon as it has them, so the rest of the file is never read. | A look at the shape of a file: the column names, how dates and numbers are written, whether the delimiter is the one you expected. |
| One row in every N | Row 1, then every Nth row after it, to the end of the file. | A spread across the whole file. The one to choose when the file is sorted by date, region or ID, where the first rows all come from one part of it. |
| Rows drawn at random | Exactly the number of rows you ask for, every row of the file equally likely to be one of them, chosen in one pass. Fewer only if the file holds fewer rows than that. | A sample you are going to measure something on, where taking rows by position would bias the answer. |
| A share of the rows | Close to that percentage of the rows, not exactly it: every row gets its own chance of being kept. | Keeping the sample proportional to the file when you do not know how many rows it has. |
Two of those differences matter more than the rest. Rows from the start is the only mode that does not read the whole file — it stops at the last row it needs, which on a large export is the difference between reading a thousand rows and reading all of them. Rows drawn at random is the only mode that holds rows in memory, because it cannot know which rows belong in the sample until the file ends; that is why it is capped at 1,000,000 rows and refuses a larger ask before it starts. The other two write each row as they meet it and hold nothing.
If you do not know how many rows the file has, the CSV analyzer counts them without writing a file. That is also how to turn “about one per cent” into a row count you can ask for outright, which A share of the rows cannot give you.
Why a Random Sample Is Repeatable
Random here does not mean different every time. The two modes that use chance — Rows drawn at random and A share of the rows — draw their numbers from a seeded generator, set to 42 under Advanced Options, and nothing else feeds into the choice. The same file, the same mode and number, and the same seed give a byte-identical sample on every run, on any machine.
That is what makes a sample worth putting in a bug report. Rather than attaching a file, the report can name the file, the mode, the number and the seed, and whoever picks it up rebuilds the same rows, the one that broke the import included. Change the seed and you get a different draw of the same size out of the same file, which is how to check that a result was not an accident of one sample.
A Sample Keeps the File’s Own Order
Rows come out in the order they were in the file, in all four modes. That is obvious for the rows from the start and for one row in every so many. It is worth saying for a random sample, because the method that picks the rows does not produce them in order: it fills a fixed set of places as the file streams past, replacing rows already in the sample as it goes, and the rows end up in whatever order the places were taken. They are sorted back into file order before a single one is written, so row 4 of the sample is always earlier in the file than row 5, and the sample can be lined up against the file it came from.
Values are not touched either. Each row is written as the exact text it arrived as, so codes keep the leading zeros Excel drops when it opens a CSV, long references keep every digit, and a quoted value holding a comma or a line break comes out quoted the way it went in. The header row is copied from the file’s own first line rather than rebuilt from the column names, and the sample keeps the delimiter and the line endings the original had. Those zeros survive the sample and are lost at the next step if the sample is opened in Excel, so when the rows are going into a spreadsheet, write the sample out as an .xlsx workbook instead of double-clicking the CSV.
Sampling Is Not Splitting
The two get confused because both turn one large file into something smaller. The difference is what happens to the rows you did not ask for: a sample leaves them behind, written nowhere, while splitting a CSV keeps every one of them.
| Tool | Which rows it keeps | What you end up with |
|---|---|---|
| Take a sample | Some of them, chosen by position or by chance | One smaller file. The rows that were not chosen are not written anywhere. |
| Split a CSV | All of them | Several files, split by rows, size or number of parts, with the header repeated at the top of each. |
| Filter CSV rows | Every row that matches the conditions you set | One file of the matching rows, and a second file of the rest if you ask for it. |
So: split when every row still has to exist somewhere, which is usually an import that will not take a file this large — splitting a CSV to fit an import limit lists the published limits. Sample when the rows you leave out are of no further use to you. And if the rows you want have something in common — one country, one status, the orders above an amount — that is neither job: filtering keeps exactly those rows and nothing else.
Making a Test File for an Import
The common reason to take a sample is to have something small enough to push through an import, a script or a staging system without waiting for the whole export. A sequence that saves a second round:
- Analyze the file first. It reports the row count, the column names, the delimiter and the encoding, which is what you need in order to choose a sample size rather than guess one.
- Take the sample with One row in every so many rather than with the rows from the start, unless you already know the file is unsorted. The rows at the top of an export sorted by date all come from the same stretch of time, and they can miss the empty columns, the accented names and the over-long values that turn up further down.
- Run the validator over the full file, not only over the sample. It reports broken rows, unclosed quotes, a wrong encoding and repeated IDs wherever in the file they are, and those are exactly what a sample of a few thousand rows can leave behind.
- Import the sample. Anything the import rejects at this size is something you would rather find now than an hour into loading the whole file.
One thing a sample cannot do is make the data safe to hand out. Every row in it is a real row, with real names and real addresses in it, so it falls under the same rules the original does. When the test system is one the real data must not reach, the sample CSV file generator is the other half of this pair: the same shape of file, the same awkward values if you ask for them, and no real person in any row of it.
Last updated .