Skip to Content
RowSlice

Guide

How to Open a Large CSV File on a Mac

Published

A CSV with a few million rows is awkward on any computer, and a Mac adds a few twists: Numbers is the default spreadsheet but Apple does not say how much it can hold, Excel for Mac lacks some of the import features of the Windows version, and commands copied from Linux guides do not always work in Terminal.

Here are the options, starting with the ones that need nothing installed. We tested the commands on a 99.4 MB export with 2,500,000 rows — in a Unix shell on Windows, not on a Mac, but using only options that Apple’s versions of the commands also have.

Excel for Mac

Excel for Mac has the same ceiling as Excel for Windows: 1,048,576 rows per sheet. Microsoft ties the limit to the file format itself — “the .xlsx file format has a limit of 1,048,576 rows per sheet” — so no version of Excel gets around it. A longer CSV is loaded up to that row, and the rows after it are not in the workbook. Do not save over the CSV at that point, or they are gone from the file too.

If the file fits, import it rather than double-clicking it, so Excel does not strip leading zeros or turn codes into dates. On Excel for Mac the importer is Data › Get Data (Power Query) › Text/CSV; converting a CSV to Excel without breaking it has the steps and the versions that include it. One feature Mac users will miss is From Folder, the Windows command for combining a folder of CSV files, which Microsoft does not list among the data sources for Excel for Mac.

Numbers

Numbers opens CSV files, but Apple does not publish a maximum number of rows or columns, and the figures you will find on forums are not official. The practical test is simple: note the row count before you open the file (see below), then check the last row in Numbers. If rows are missing, or Numbers becomes unresponsive, split the file into parts and open those instead.

Look Inside Without Opening It: Terminal

Often you only need to see what is in the file — the column names, a few rows, the delimiter. Terminal commands handle that at any size, because they read the file as a stream instead of loading all of it:

head -n 20 big.csv
wc -l big.csv
less -S big.csv
  • head -n 20 prints the first 20 lines: the header and, unless some values contain line breaks, the first 19 rows. It returns immediately, whatever the file size.
  • wc -l counts line breaks, which is not quite the row count. On our test file it reported 2,525,775, while a CSV parser counted 2,500,000 rows plus the header: the difference is values with line breaks inside them. Counting the rows in a CSV explains how to get the exact figure.
  • less -S lets you scroll through the file with the arrow keys, with long lines cut at the edge of the window instead of wrapped. Press q to quit.

To use them, open Terminal, type cd followed by a space, drag the folder containing the CSV from Finder into the window, and press Return.

Split It in Terminal

macOS includes split, but it is the BSD version, and it lacks options such as --additional-suffix that Linux guides often use. This version works on both, puts the header back on every part and names the parts part_aa.csv, part_ab.csv and so on:

tail -n +2 big.csv | split -l 1000000 - part_
for f in part_*; do
  { head -n 1 big.csv; cat "$f"; } > "$f.csv" && rm "$f"
done

Change 1000000 to the number of lines you want per part, and run it in a folder that has no other files starting with part_. It counts lines, not rows, so if your data has line breaks inside values it can cut a row in half; splitting a CSV from the command line shows when that happens and a script that avoids it.

Query It with DuckDB

When you need answers from the data rather than a spreadsheet of it — totals, counts, the rows for one store — DuckDB is the most capable free option. It is a single program that runs SQL directly on CSV files. Install it with brew install duckdb if you use Homebrew, or with the installer command on duckdb.org, then type duckdb in Terminal and run queries such as:

SELECT count(*) FROM 'big.csv';
SELECT * FROM 'big.csv' LIMIT 20;
COPY (SELECT * FROM read_csv('big.csv', all_varchar = true) WHERE store = 'Paris') TO 'paris.csv';

The first counts rows properly, line breaks inside values included; on our file it returned 2,500,000. The second shows the first 20 rows as a table. The third writes every row for one store to a new CSV that is small enough to open in a spreadsheet — 62,500 rows in our test. all_varchar = true keeps each value exactly as it was: without it, DuckDB read amount as a number and wrote 0 back out as 0.0.

In the Browser, with Nothing Installed

The tools on this site run in the browser, so there is nothing to install. We test them in current versions of Chrome, Edge and Firefox; we have not tested Safari, so we make no claim for it. They read the file from your disk in small pieces, so nothing is uploaded and a multi-gigabyte file needs no more memory than a small one:

They do write their output to disk as they go, so you need roughly as much free space as the file itself takes.

Which to Use

You want to…Use
See the columns and a few rowshead or less -S in Terminal
Know how many rows there areDuckDB’s count(*), or a browser tool
Work with it in Excel or NumbersSplit it into parts under 1,048,576 rows first
Get one region’s or client’s rowsSplit by column value, or a DuckDB WHERE query
Total, group or filter all of itDuckDB

For more on each route, including Excel’s Data Model on Windows, see opening a CSV that is too large for Excel.

FAQ

Frequently Asked Questions

How many rows can Excel for Mac open?

1,048,576 per sheet, the same as Excel for Windows, because the limit belongs to the file format: Microsoft states that “the .xlsx file format has a limit of 1,048,576 rows per sheet.” The header takes one of those rows. A longer CSV is cut off at that row, so split it first or keep the data outside the grid.

How many rows can Apple Numbers open?

Apple does not publish a maximum, and we have not found an official figure; numbers quoted online come from forums and third-party sites. Compare the row count Numbers shows with the real count of the file. If they differ, the import stopped early, and splitting the CSV into smaller parts is the reliable fix.

Should I save as “CSV (Macintosh)” on a Mac?

Almost never. Despite the name, that format is for programs from the classic Mac OS: when we saved with it, Excel used the old Mac Roman character set and ended lines with a lone carriage return. Choose CSV UTF-8 (Comma delimited) unless a program asks otherwise. CSV UTF-8 vs CSV compares the formats byte by byte.

Does a Mac have a split command?

Yes. macOS includes the BSD version of split, with options such as -l for a number of lines per part and, on current versions, -d for numbered parts. It lacks some options found in Linux guides, such as --additional-suffix, so commands copied from those can fail. The command in this guide uses only the options both share.

Do I need to install Python to work with a large CSV on a Mac?

No. head, wc, less and split come with macOS, DuckDB installs as a single program, and the browser tools here need nothing installed. If you do want Python, note that Apple removed Python 2.7 in macOS 12.3 and told developers to use Python 3, which you may have to install yourself.

Why do accented letters look wrong when I open the CSV?

The program guessed the wrong character set. CSV files cannot say which one they use, so a UTF-8 export can be read as an older encoding and Café shows as Café. The file itself is usually fine. CSV encodings explained covers the causes, and the encoding fixer converts the file to UTF-8 with the marker Excel looks for.

Guides

See All 20 CSV Guides