How to split a large CSV file into smaller files
Split a big CSV by rows or size with the header in every part, a worked example for Excel, and the command-line way explained fairly.
By OpenAnyDoc · ·
The short answer
Cut the file by a number of rows or by a size in MB, and put the header row at the top of every part so each file opens on its own. For Excel, keep each part under 1,048,576 lines, header included. OpenAnyDoc's Split CSV does both in your browser: choose rows or MB per file and download all the parts as one ZIP, without uploading the file.
Why every part needs the header row
The first line of a CSV names the columns: order_id, order_date, region, amount. A plain cut leaves that line only in the first part. The second part starts in the middle of the data, so Excel shows a row of numbers where the column names should be, an import form maps the columns wrongly or refuses the file, and an AI chat has to guess what each value means.
The second trap is a field that holds a line break inside quotes, such as an address or a comment. A tool that counts text lines can cut that record in two, leaving half of it at the end of one part and the rest at the top of the next. Splitting by records, not by lines, avoids it.
How to split a CSV in your browser
Split CSV reads the file on your device; nothing is sent to a server:
- Open Split CSV and drop the .csv file on the page, or choose it. Once the table is read, the download dialog opens with "Split into several files (a .zip)" already ticked.
- In "Split by", keep "Rows per file" and type a number (10,000 is filled in), or pick "Size per file" and enter the MB per file. Under the rows box the dialog tells you how many files you will get.
- Press Download. You get one ZIP named after your file, such as orders-parts.zip, holding orders-part-1.csv, orders-part-2.csv and so on, each starting with the header row.
- To split only some of the data, close the dialog, filter the rows or hide the columns you don't need, then choose "Download options…" in the More menu, tick the shown-rows option and tick the split option again.
- A file over 50 MB shows a warning that it may be slow, then still opens if your browser has the memory. There is no row limit of its own. To look through a big file before you split it, use the large CSV viewer.
A worked example: 2,500,000 rows for Excel
Say an export has a header and 2,500,000 data rows. An Excel worksheet holds 1,048,576 rows, header included (Microsoft's Excel specifications and limits, checked 24 November 2026), so one part can carry at most 1,048,575 data rows. A round 1,000,000 rows per file leaves room and is easy to check:
- 2,500,000 ÷ 1,000,000 = 2.5, so you get 3 files.
- Part 1: the header and rows 1 to 1,000,000, so 1,000,001 lines.
- Part 2: the header and rows 1,000,001 to 2,000,000, so 1,000,001 lines.
- Part 3: the header and rows 2,000,001 to 2,500,000, so 500,001 lines.
- Every part is under 1,048,576 lines, and the parts add up to 2,500,000 data rows: nothing is lost and nothing is counted twice.
What we measured on a test file
We made a synthetic file of orders (order_id, order_date, region, product_code, quantity, amount) with 250,000 data rows and 9.51 MB, and ran it through the same splitting rule the page uses:
- 100,000 rows per file: 3 parts with 100,000, 100,000 and 50,000 data rows, each with the header.
- 5 MB per file: 2 parts with 128,221 and 121,779 data rows, 4.88 MB and 4.63 MB. Size mode cuts between rows, so a part ends at the last whole row that fits and usually lands a little under the number you type.
- A plain split -l 100000 of the same file on macOS: 3 parts, and only the first had the header; the other two started with an order row.
Choose the part size for where the file is going
The right number depends on what will read the parts:
- Excel: up to 1,048,575 data rows per part; 1,000,000 is a safe round number. If Excel is slow even below the row limit, the guide on how to open a large CSV file covers the other options.
- An upload form with a size limit, such as 10 MB: use "Size per file" and set it a little lower, for example 9 MB, because each part is about that size, not exactly.
- An AI chat: what counts there is tokens, not rows. Count one part with the Token counter, then pick a number of rows that fits. File too large for ChatGPT explains the limits.
- If a part opens in one column in Excel, the split is fine; the separator does not match your PC. CSV opens in one column explains the fix.
The command-line alternative
On macOS and Linux, split -l 1000000 orders.csv part_ cuts a file into pieces of 1,000,000 lines. It does some things better than a browser: it reads the file as a stream, so the file can be larger than your memory, it is fast, and it fits in a script that runs every night. Two things to know: it does not repeat the header, so only part_aa has the column names, and it counts text lines, not records, so a quoted field with a line break inside can be cut in two. split -b cuts at a byte count and can break a row in the middle.
To repeat the header, split everything after the first line, then put the header back on each piece. On our test file these two commands gave three .csv parts that each start with the header. They still count lines, so use them only when no field holds a line break:
- tail -n +2 orders.csv | split -l 1000000 - part_
- for f in part_*; do (head -n 1 orders.csv; cat "$f") > "$f.csv"; rm "$f"; done
Does every part keep the header row?
Yes, every part made by Split CSV starts with the original header row, so each file opens or imports on its own. If the parts go into a system that wants data rows only, untick "Include the header row" in the same dialog before you press Download, and every part then holds just the rows.
Can I split a CSV by the values in one column?
Not in one step: Split CSV cuts by rows or by size, not by the values in a column. To get one file per region, filter the region column to one value, download the shown rows, and repeat for each value. With a handful of values that takes a few minutes; with hundreds of them, a script is quicker.
How do I put the parts back into one file?
Use Merge CSV: add the parts in order and it writes one CSV with a single header row. Columns are matched by name, so a part whose columns sit in a different order still lines up. Every part needs the same column names in its header, which is one more reason to keep the header in each part.
Questions?
Write to support@openanydoc.com with the file size, the row count and where the parts need to go (no personal data).