LARGE CSV · PRACTICAL GUIDE
How to Split a Large CSV File
A CSV that will not open in Excel, slows your computer, or is too awkward to share becomes easier to handle when it is divided for the right reason. This guide compares Excel, Power Query, Python, and LocaCSV, then shows how to split rows by a column value without corrupting CSV quoting or line breaks.
The short answer: choose the method that matches the split
For a CSV up to 50 MiB, LocaCSV can split by column value, a fixed number of data rows, or a target file size entirely in your browser, then package up to 100 outputs in a ZIP archive.
For inputs over 50 MiB, compound keys, or scheduled workflows, a local Python script offers more control. Opening a very large CSV directly in Excel and cutting it apart manually is usually the least reliable option because worksheet limits, memory pressure, and copy-and-paste mistakes all become more likely as the file grows.
Why a large CSV may not open
CSV is plain text, but the program opening it still has limits. An Excel worksheet has 1,048,576 rows. A file beyond that cannot fit on one sheet. Even below the row limit, imports can become slow because of wide records, long cells, type detection, quoting, available memory, or an incorrect delimiter.
- The file has more rows than an Excel worksheet can hold.
- The application expands the file in memory and the computer runs out of available resources.
- The delimiter is detected incorrectly, turning one record into an extreme number of columns.
- A simple line or comma split breaks quoted commas, escaped quotes, or line breaks inside a cell.
- The selected encoding does not match UTF-8, Windows-1252, or another legacy encoding used by the source system.
- Excel automatically converts IDs, leading zeros, long numbers, or date-like text.
Excel vs. Power Query vs. Python vs. LocaCSV
The right tool depends on the split rule, file size, frequency, and whether you can maintain code. The table below summarizes the practical tradeoffs.
| Method | Best for | Advantages | Limitations |
|---|---|---|---|
| Excel | A smaller file that you need to inspect and divide once | Familiar visual interface | 1,048,576-row worksheet limit; large imports are slow and manual splitting risks missing or duplicating rows |
| Power Query | Reusable imports and transformations inside Excel | Keeps the source intact and lets you refresh recorded steps | Loading to a worksheet still has the row limit; exporting one CSV per value needs additional design |
| Python | Files over 50 MiB, fixed row or size rules, and repeatable jobs | Fine control over streaming, names, validation, and automation | You maintain the runtime, code, tests, encoding, and error handling |
| LocaCSV | Quickly splitting up to 50 MiB by value, rows, or target size | No account or install; processing stays in the browser and outputs arrive as a ZIP | 100 outputs maximum; value mode accepts one split column |
import csv
from pathlib import Path
source = Path("large.csv")
output_dir = Path("split")
output_dir.mkdir(exist_ok=True)
handles = {}
writers = {}
try:
with source.open("r", encoding="utf-8-sig", newline="") as input_file:
reader = csv.DictReader(input_file)
key_column = "department"
for row in reader:
key = row.get(key_column, "") or "(blank)"
if key not in writers:
output = output_dir / f"group-{len(writers) + 1:03d}.csv"
handle = output.open("w", encoding="utf-8-sig", newline="")
writer = csv.DictWriter(handle, fieldnames=reader.fieldnames)
writer.writeheader()
handles[key] = handle
writers[key] = writer
writers[key].writerow(row)
finally:
for handle in handles.values():
handle.close()How to split a CSV with LocaCSV
LocaCSV parses commas, double quotes, escaped quotes, and line breaks inside cells as CSV structure. The preview is your best early warning: if columns do not line up there, correct the delimiter or encoding before running the split.
- Open the CSV Splitter and select one CSV file.
- Confirm whether the file has a header, then check the input encoding and delimiter. Do not continue if the preview is misaligned.
- Choose Column value, Row count, or Target size as the split method.
- For value mode, set the column and blank handling; for the other modes, enter data rows per file or a target size in MiB.
- Confirm the output encoding, UTF-8 BOM option, and output delimiter, then start the split.
- Review input rows, output and excluded rows, output-file count, and warnings before downloading the ZIP.
How splitting by a column value works
Value-based splitting creates a separate file for each category in one column—for example store, department, customer, or month. If a Store column contains London, Madrid, and Seoul, every row with the same value goes to the same output, producing three CSV files.
If headers are duplicated, absent, or padded with spaces, use the preview and one-based column number to confirm the target. When a value contains characters that Windows cannot use in a filename, or matches a Windows reserved name, LocaCSV converts the output name to a safe form.
- Rows with the same value stay in the same output file.
- Blank values can be excluded or written to a dedicated output.
- One column can be selected per run.
- If more than 100 unique outputs would be created, processing stops and no partial ZIP is published.
- Before exposing the ZIP, the tool checks that input rows equal output rows plus excluded rows.
Row-count and file-size cautions
File size alone does not predict how difficult a CSV is to process. Two 50 MiB files can behave differently when one has millions of short records and the other contains very long cells or many quoted line breaks.
The public LocaCSV Free limit for a single-input tool is one file up to 50 MiB. Device performance, browser behavior, CSV shape, and output volume can make a smaller file difficult as well. Renaming a larger file or passing a compressed archive does not bypass the limit.
- Row-count mode excludes the header from the number of data rows per file.
- Target-size mode uses actual bytes after output encoding, including the BOM and repeated header. A single oversized CSV record stays intact in its own file.
- There can be at most 100 output files; estimate unique values or row-based output count first.
- Keep the source unchanged, save the ZIP separately, and verify counts before replacing any downstream data.
- If the outputs are intended for Excel, check that each remains below 1,048,576 rows.
Character encoding and garbled text
UTF-8 is common, while files from older Windows or Western European systems may use Windows-1252. LocaCSV auto-detects UTF-8 and Shift_JIS as candidates; CP949, Big5, GB18030, and Windows-1252 are manual choices. When detection is uncertain, use the preview rather than treating the guess as final.
For Excel, UTF-8 with a BOM is sometimes recognized more reliably. If a downstream system requires a legacy encoding, choose it only when every character can be represented. LocaCSV stops instead of silently replacing an unsupported character with a question mark.
- Check names, punctuation, currency symbols, and accented letters in the preview.
- Do not confuse a delimiter error with an encoding error: shifted columns usually point to comma, semicolon, tab, or pipe selection.
- If the source encoding is unknown, check the export settings of the system that created the file.
- Do not save a garbled preview and overwrite the source; start again from the original file.
Security and local processing
LocaCSV runs CSV processing in a Web Worker inside your browser. The CSV body, filename, headers, cell values, and split values are not uploaded to an external server for processing. Results are assembled locally, and retained references are released after download or reset.
The public information site uses Cloudflare Web Analytics for page views. The processing site does not load advertising or analytics SDKs. It sends only identifier-free, first-party usage events limited to fields such as the operation, size bucket, duration bucket, and fixed error code. Events do not contain CSV contents, filenames, exact sizes, or row counts, and a failed event does not block processing or download.
For confidential data, also consider your organization’s policy, device security, browser extensions, and permissions on the download folder. Browser-local processing does not make the entire device automatically secure.
Large CSV splitting FAQ
Can I split a CSV that Excel cannot open?
If the CSV is 50 MiB or smaller, uses a supported encoding and delimiter, and would create no more than 100 outputs, LocaCSV can split it. A CSV can be read even when its row count exceeds an Excel worksheet, but the practical limit still depends on the device and CSV structure.
Can I split every 100,000 rows or every 10 MB?
Yes. Row-count mode counts data rows without the header. Target-size mode accepts 0.1–50 MiB and measures encoded output bytes, including the BOM and repeated header. One record is never cut, so an individually oversized record may exceed the target.
Can I process a CSV larger than 50 MiB?
The public Free version limits a single-input tool to one file up to 50 MiB. LocaCSV does not currently claim support for larger files in the public tool, so split the source locally first.
Can I convert Windows-1252 input to UTF-8?
Yes. Select Windows-1252 manually as the input, then choose UTF-8 with or without a BOM for output. Always confirm accented letters and punctuation in the preview.
Is my CSV uploaded to a server?
The CSV body, filename, headers, cell values, and split values are not uploaded for processing. Splitting and ZIP creation run inside your browser.