Large CSV files cause problems at the worst moment. The CRM import page accepts files up to a certain size. The email platform wants no more than a set number of contacts per upload. Excel opens the file and warns that it did not load completely. Or a colleague only needs the rows for their own region, not the whole national dataset.
Splitting the file solves all of these, but it has to be done carefully. A CSV is not just lines of text: every part needs the header row, and a quoted field with a line break inside it must never be cut in half. This guide covers the three useful ways to split, the tools that do it (in the browser, in PowerShell, with split and awk, and in pandas) and how to check the result.
Three ways to divide a CSV
| Split by | Use it when | Example |
|---|---|---|
| Rows per file | A system has a row or size limit per upload | 10,000 contacts per file for an email tool |
| Number of files | You want equal shares for people or parallel jobs | Four equal lists for four sales reps |
| Column value | Each group goes to a different owner or system | One file per region, country or store |
Rows per file and number of files are two views of the same arithmetic. With 25,000 data rows and 10,000 rows per file you get three files (10,000, 10,000 and 5,000). Asking for four files from 25,000 rows gives 6,250 rows each.
Splitting by column value is different in kind: the number of files depends on how many distinct values the column contains, and each file can have a different size.
Why a naive split breaks the data
It is tempting to split a CSV like a log file, every N lines. Two things go wrong:
- Only the first part has a header. Every other part starts with data, so the importer either treats the first data row as column names or rejects the file.
- Quoted line breaks get cut. An address or comment field such as
"Unit 4,\nRiverside Park"spans two physical lines but is one row. Splitting between those lines produces a broken row at the end of one file and a broken row at the start of the next.
A CSV-aware splitter parses the file into rows first, then counts rows rather than lines, and writes the header into every part.
Split a CSV in your browser
The CSV Splitter parses the file properly and packages all parts in one ZIP, without uploading anything.
- Open the CSV Splitter and click Open CSV file, or paste data into CSV input. Load sample loads a small order list set to three rows per file.
- Leave Delimiter on Auto-detect unless the file uses an unusual separator.
- Choose Split by: Rows per file, Number of files or Column value, then set the number or pick the Column.
- Keep First row is header (repeat in every file) on so each part starts with the header row.
- Check the list of parts and their row counts. Download a single part with its download icon, or click Download all (.zip).
Parts are named after the original file, for example orders-part001.csv, or orders-EMEA.csv when splitting by column value. Files up to 200 MB can be opened; for very large inputs the text box is hidden to keep the page responsive, but splitting still works.
Other ways to split a CSV
PowerShell (Windows)
PowerShell's CSV cmdlets handle quoting and write headers for you:
$rows = Import-Csv .\contacts.csv
$size = 10000
for ($i = 0; $i -lt $rows.Count; $i += $size) {
$n = [math]::Floor($i / $size) + 1
$rows[$i..([math]::Min($i + $size, $rows.Count) - 1)] |
Export-Csv ".\contacts-part$n.csv" -NoTypeInformation -Encoding UTF8
}
Splitting by a column is a one-liner with Group-Object:
Import-Csv .\orders.csv | Group-Object region |
ForEach-Object { $_.Group | Export-Csv ".\orders-$($_.Name).csv" -NoTypeInformation }
Import-Csv loads the whole file into memory, so it is slow for files of several gigabytes.
split and awk (macOS, Linux, WSL)
For huge files without embedded line breaks, the classic tools are fast and stream the data. GNU split (Linux) can repeat the header by piping each chunk through a filter:
tail -n +2 contacts.csv | split -l 10000 -d --additional-suffix=.csv \
--filter='{ head -n 1 contacts.csv; cat; } > $FILE' - part-
awk can split by the value of a column, here the second one, assuming a simple comma-separated file with no quoted commas:
awk -F, 'NR==1 { h=$0; next } { f=$2 ".csv"; if (!(f in seen)) { print h > f; seen[f]=1 } print > f }' orders.csv
The macOS version of split lacks the GNU-only options used above. Both approaches work on lines, not CSV rows, so check your data for quoted line breaks and commas first.
Python with pandas
pandas can read a large file in chunks, so memory use stays low:
import pandas as pd
for i, chunk in enumerate(pd.read_csv("contacts.csv", chunksize=10_000, dtype=str), start=1):
chunk.to_csv(f"contacts-part{i:03}.csv", index=False)
df = pd.read_csv("orders.csv", dtype=str)
for region, group in df.groupby("region"):
group.to_csv(f"orders-{region}.csv", index=False)
dtype=str stops pandas from dropping leading zeros or rewriting numbers in the output.
Tips and pitfalls
Choosing a chunk size for Excel
An Excel worksheet holds 1,048,576 rows including the header. A file larger than that needs splitting before Excel can show all of it; parts of up to 1,000,000 data rows are a comfortable choice. For simply looking at a large file, the CSV & Excel Viewer may be enough.
Size limits are about bytes, not rows
If an importer limits file size rather than row count, estimate the bytes per row: divide the file size by its row count and pick a row count with some margin. Wide rows with long text fields take more space than narrow numeric ones.
Messy group values
When splitting by column value, EMEA, emea and EMEA (with a trailing space) are three different groups. Clean the column first so you don't end up with near-duplicate files. Empty values go into a file named with blank.
Putting the pieces back together
Parts produced with a repeated header can be recombined with the CSV Merger, which removes the extra header rows automatically because it matches columns by name. For non-CSV text such as plain lists, the Text Splitter splits by lines or characters instead. If your data starts in a workbook, export each sheet first with Excel to CSV.
Frequently asked questions
How do I split a CSV file and keep the header in each file?
Use a CSV-aware splitter that repeats the first row in every part. In the CSV Splitter, keep First row is header (repeat in every file) switched on.
Can I split a CSV by the values in one column?
Yes. Choose Column value under Split by and select the column; one file is created for each distinct value.
What is the maximum number of rows Excel can open?
A worksheet holds 1,048,576 rows. Excel warns when a CSV is larger and loads only the rows that fit.
Why do some split files have broken rows?
The file was probably split by lines, cutting through a quoted field that contained a line break. Split by parsed rows instead.
Is it safe to split confidential files online?
The CSV Splitter runs in your browser and does not upload the file, so the data stays on your device.