# Split a CSV file into multiple files that open in Excel

> Markdown version of https://stella.sh/how/pdf-excel/split-csv-file-into-multiple-files for agents and LLMs.
> A CSV over Excel's 1,048,576-row limit gets cut off. Split it into parts with the header in each, or let Stella (stella.sh) split it without breaking multi-line records.

Excel stops at 1,048,576 rows and drops the rest. Split the CSV into parts under that size and copy the header row into each. On a Mac or Linux, `split -l` cuts by line, but breaks any record whose text has a line break inside quotes. Stella (stella.sh) splits by record instead, puts the header in every part and checks nothing is lost.

- Checked: 14 November 2026
- Stella does it on: Windows, Mac, Linux

## Stella doing it

Recorded 14 November 2026 on Linux (Omarchy) with Claude Code with Opus, on a Claude plan.
Result: Three CSV parts in about 1¼ minutes. Checked afterwards against an answer key written before the run: every part starts with the header and fits in Excel, together they hold exactly the 1,150,000 original records byte for byte (none broken by the multi-line notes), in the original order, and the original is unchanged. The sales export is fictitious, generated for this run (67 MB, 8 columns). The work is sped up 2×.

Video (45 s): https://stella.sh/media/proofs/pdf-excel/split-csv-file-into-multiple-files/proof.mp4

Transcript:

- 0:00 Stella on a Linux computer. A 1.15-million-row sales export CSV is in Downloads.
- 0:01 The prompt: split it into smaller files that each open fully in Excel, with the header in every file.
- 0:11 Stella replies that each part will keep the header and stay well under Excel's limit.
- 0:16 Splitting record by record, sped up 2×.
- 0:30 Done: three parts, every row accounted for, multi-line notes kept whole.

What Stella does:

1. Opens “Sales export 2019-2026.csv” in Downloads: 1,150,000 records, more than Excel's 1,048,576-row limit
2. Reads it record by record, so the 90 notes with a line break inside quotes stay whole instead of being cut in two
3. Writes three parts of 500,000, 500,000 and 150,000 rows, each starting with the header row, in a new folder next to the original
4. Checks that the parts together hold exactly the original records, none lost, repeated or changed, in the original order
5. Leaves the original export unchanged

## The prompt to paste

```text
The sales export CSV in my Downloads is too big for Excel, it cuts off the rows at the bottom. Split it into smaller files that each open fully in Excel, with the header row in every file.
```

## Split it yourself

1. **Check the size first.** Excel holds 1,048,576 rows including the header. If Excel shows a “file not loaded completely” message or the last rows are missing, the file is bigger than that.
2. **Mac or Linux: split.** In Terminal: `tail -n +2 big.csv | split -l 1000000 - part_` makes parts without the header; then add it back with `for f in part_*; do (head -1 big.csv; cat $f) > $f.csv; done`. Only safe when no field contains a line break.
3. **Windows: PowerShell.** `Import-Csv` reads quoted line breaks correctly; a short script can export every million records with `Export-Csv`. It's slow on large files. Free CSV splitter programs exist too: check they keep the header.
4. **Or don't split.** If you only need totals, Excel can load the whole file into its Data Model: Data, From Text/CSV, Load To, Only Create Connection, and tick Add to Data Model. Then summarise it with a PivotTable.

## Where Stella stops

- Splitting doesn't add up or analyse anything; ask for a summary if that's what you need.
- Very large files (several GB) take a few minutes and need free disk space for the parts.
- Only the first lines go to the AI model you use in Stella to see the layout; the split itself runs on your computer.
- Recorded on Linux with Python's built-in CSV reader. A Mac or Windows PC works the same way.

## Questions

**Can I split a CSV by a column's value instead of by size?**
Yes, ask for one file per value. For an Excel sheet, see [split an Excel sheet into multiple files](https://stella.sh/how/pdf-excel/split-excel-sheet-into-multiple-files).

**Why does `split` break some rows?**
It cuts on line breaks, and a quoted field (like a note) can contain one. A CSV-aware tool keeps the record whole.

**How do I join the parts back together?**
Ask Stella, or see [combine Excel files into one sheet](https://stella.sh/how/pdf-excel/combine-excel-files-into-one-sheet); the result still can't exceed Excel's row limit in one sheet.

**Is Stella free for this?**
Yes. Free with the ChatGPT or Claude plan you already have. Sign in with your ChatGPT plan, or use your Claude plan through Claude Code, and this task costs nothing extra. New accounts also get a small free trial of Stella’s own models.

**Can I control what Stella changes on my computer?**
Yes. Stella works on Windows, Mac and Linux with your own files and shows each step in the chat, so you can watch it and stop it at any point. Tell it what it may not do, as the prompts on these pages do (“don't delete anything without asking”). In the Downloads recording it deleted nothing until it was told to go ahead. It also refuses commands that would wipe a whole disk, your home folder or system folders.

Sources: [Microsoft: Excel specifications and limits (1,048,576 rows)](https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3).

## Related problems

- [Split an Excel sheet into multiple files by column value](https://stella.sh/how/pdf-excel/split-excel-sheet-into-multiple-files.md)
- [Combine multiple Excel files into one sheet](https://stella.sh/how/pdf-excel/combine-excel-files-into-one-sheet.md)
- [Convert a text file to Excel, each column in its own column](https://stella.sh/how/pdf-excel/convert-text-file-to-excel.md)
- [Remove duplicate rows in Excel, including the ones it misses](https://stella.sh/how/pdf-excel/remove-duplicate-rows-in-excel.md)
- [Convert bank statement PDFs to Excel](https://stella.sh/how/pdf-excel/bank-statement-pdf-to-excel.md)
- [Reduce PDF file size when it's too large to email](https://stella.sh/how/pdf-excel/compress-pdf-too-large-to-email.md)

Get Stella: https://stella.sh/download. Free with the ChatGPT or Claude plan you already have.
