Caxton
Features Benchmarks Pricing Docs How it works Changelog Support About Download Free
Guides
All guides Large File Text Editors EmEditor for Mac UltraEdit Alternatives Notepad++ Alternatives Notepad for Mac Free Text Editors for Mac File Too Large for VS Code CSV Editor for Mac Open a CSV File CSV Viewer for Mac Open a TSV or Pipe-Delimited File Edit CSV Without Auto-Formatting Repair a Malformed CSV Remove Duplicate Rows Validate a CSV Transform a CSV Column Fixed-Width to CSV Change a CSV Delimiter Split a Large CSV Combine CSV Files Sort a Large CSV CSV Too Big for Excel Open a Huge CSV Log Viewer for Mac View Log Files Follow a Live Log File CMTrace for Mac Open a 10 GB Log Filter Large Log Files Jump to a Time in a Log Find & Replace in Huge Files Find & Replace Across Files Regex Cheat Sheet Compare Two Text Files Open a SQL Dump Fix Garbled Text & Encoding Convert a File to UTF-8 Remove a BOM Convert Line Endings Remove Invisible Characters Smart Quotes to Straight Quotes Sort & Dedupe Lines Open a GBK or Big5 File Open a UTF-16 or Shift-JIS File Open a Large JSON File Numbers File Too Large

How to combine multiple CSV files into one on a Mac.

A year of monthly exports, a report that arrives as one file per region, a download that came in twenty parts: sooner or later the rows have to be stacked into one CSV file. It takes a single command when the files match. When they do not, it goes wrong quietly, with a header row repeated in the middle of the data, columns that line up by position and not by name, or one file in another delimiter or encoding. This guide starts with the checks worth making first, then shows the free tools, beginning with the commands every Mac already has, and where each one stops.

Download Caxton for Free · 7-day free trial of Caxton Pro, no credit card required · 8 MB · macOS 13.0+

The short answer

In Terminal, awk 'FNR == 1 && NR != 1 { next } { print }' *.csv joins every CSV file in a folder and keeps only the first header row, free on any Mac, where a plain cat repeats the header of every file. csvstack from csvkit and read_csv in DuckDB are free as well, and each can add a column that names the file a row came from. Caxton, a native Mac editor for text and data files, does it from File ▸ Combine Files…, which keeps the header once, writes every row with the first file's delimiter, can add a source column, and lists the files whose columns differ before anything is written.

What should I check before I combine CSV files?

Stacking rows only gives a table when the files agree on three things: the columns, the delimiter and the encoding. Two commands that ship with macOS show all three. Run them in Terminal from the folder that holds the files.

head -n 1 *.csv
file -I *.csv

Do the columns match? head -n 1 prints the first line of every file, and Apple's manual page explains the layout: "If more than a single file is specified, each file is preceded by a header consisting of the string “==> XXX <==” where “XXX” is the name of the file." Read the header rows against each other. Most ways of combining append by position, so the third field of every row lands under the third header whatever it holds, and a file with its columns in another order puts values in the wrong column without any error.

Do the delimiters match? The same output shows whether one file separates its fields with semicolons or tabs while the others use commas. A tool that copies lines leaves that file as it is, and its rows no longer split into the same columns as the others. Changing a CSV's delimiter has its own guide.

Do the encodings match? file -I reports a charset for each file. A set that is all us-ascii and utf-8 is safe to combine. A file reported as iso-8859-1 or utf-16le among them needs converting first when you combine with cat or awk, which copy each file as it is, or its accented letters will be garbled in the result. iconv writes a converted copy:

iconv -f WINDOWS-1252 -t UTF-8 sales-2026-03.csv > sales-2026-03-utf8.csv

Put the name of the real source encoding after -f, then move the original out of the folder so that the commands below do not pick up both copies. file names a family and not the exact code page: the Windows-1252 file in this example is reported as iso-8859-1. Fixing garbled text and the wrong encoding shows how to find the right one.

Why does cat repeat the header row of every file?

cat is the command most people try first, and it is free on every Mac. Apple's manual page describes it in one sentence: "The cat utility reads files sequentially, writing them to the standard output." Name the files in the order you want them and send the output to a new file:

cat sales-2026-01.csv sales-2026-02.csv sales-2026-03.csv > all.csv

cat copies bytes. It does not know that the first line of a CSV is a header, so it copies the header of every file along with its rows. Three files give three header rows, and two of them sit in the middle of the data, where the program that reads the file next will treat them as records. A second problem appears when a file does not end with a line break: the first line of the next file continues on the same line as the last row.

cat is the right tool when the files have no header row of their own. The usual case is a large CSV that was cut into parts by the split command, which leaves the header at the top of the first part only. Joined in order, those parts give back the original file byte for byte. Splitting a large CSV on a Mac covers the cutting.

How do I merge CSV files and keep only one header row?

awk also ships with macOS, and one short rule fixes the repeated header: skip the first line of every file except the first file.

awk 'FNR == 1 && NR != 1 { next } { print }' *.csv > ../combined.csv

The manual page defines the two counters. NR is the "ordinal number of the current record" and FNR is the "ordinal number of the current record in the current file." A line is the first of its file when FNR is 1, and it is the first line of all when NR is 1 as well, so the rule drops every header but the first and prints everything else. The shell expands *.csv in alphabetical order, which is why file names that sort by date are worth having. The result goes one folder up, so that a second run does not read its own output as one more input.

Run on three files where one row holds a quoted line break and one file ends without a line break, the command gives one header and every row, with the missing line break added. It has two limits. It counts lines and not CSV records, so the header has to be a single line. It also does not compare the files, so a file with different columns, another delimiter or another encoding is appended as it is.

How do I combine CSV files with csvstack?

csvstack belongs to csvkit, which its documentation introduces as "a suite of command-line tools for converting to and working with CSV." The suite is open source under the MIT License. It is not part of macOS, and its tutorial gives the install commands. The tutorial also describes the job: "csvstack allows you to “stack” the rows from CSV files with the same columns (and identical column names)."

csvstack sales-2026-01.csv sales-2026-02.csv sales-2026-03.csv > combined.csv

Its option for the source file is --filenames, documented as "Use the filename of each input file as its grouping value." A grouping value is added "to the output as a new column," and the tutorial gives the reason for wanting one: "so that you can tell which file each row came from."

csvstack --filenames sales-2026-01.csv sales-2026-02.csv sales-2026-03.csv > combined.csv

Two more facts from the documentation matter here. The changelog for version 1.1.1 records that "csvstack handles files with columns in different orders or with different names," which makes it the free tool to reach for when the header rows do not match. The reference page also warns about writing over an input: "If you redirect output to an input file like csvstack file.csv > file.csv, the file will grow indefinitely." The command takes one -d delimiter and one -e encoding for its input, so convert a file that differs from the others before you stack it.

How do I combine CSV files with DuckDB?

DuckDB is a free database system released under the MIT License, and it has to be installed first. Its documentation opens the subject in one sentence: "DuckDB can read multiple files of different types (CSV, Parquet, JSON files) at the same time using either the glob syntax, or by providing a list of files to read." A pattern names the files, and COPY writes the result, header included, to a new CSV:

COPY (SELECT * FROM read_csv('sales/*.csv')) TO 'combined.csv';

What that plain form does with files that differ is documented precisely: "By default, DuckDB reads the schema of the first file provided, and then matches the columns of subsequent files to it by column name: columns missing from the first file are dropped, and columns of the first file missing from a later file cause an error."

Two options of read_csv answer the harder cases. filename = true adds, in the documentation's words, "an extra filename column to the result that indicates which row came from which file." The column holds a path, because "Relative or absolute paths are returned depending on the path or glob pattern provided to read_csv, not just filenames." union_by_name = true matches the files by header name: "Align columns from different files by column name instead of position." With it, the Combining Schemas page explains, "the columns are correctly unified, and any missing values are set to NULL," and the same page notes that "Using the union_by_name option increases memory consumption."

COPY (
  SELECT *
  FROM read_csv('sales/*.csv', union_by_name = true, filename = true)
) TO 'combined.csv';

Two cautions come from the same documentation. The reader "automatically deduces types of columns," and the option all_varchar = true, documented as "Skip type detection and assume all columns are of type VARCHAR," keeps every value as text when that matters. On encodings the page is specific: "DuckDB's CSV reader supports UTF-8 (default), UTF-16, and Latin-1 encodings."

How do I combine CSV files in Caxton?

In Caxton the job is one command. File ▸ Combine Files… reads every file as a CSV, compares the files before it writes anything, and puts the result in a new document, so the files you chose stay as they are. Combine Files is Caxton Pro, which every download includes as a 7-day free trial of Caxton Pro with no credit card required. On Caxton Free the command stops with a message that it needs Caxton Pro, and opening the files to read them is free at any size.

1. Choose the files

File ▸ Combine Files… puts up an Open panel that asks for two or more files to combine into one new document. Select them together, with a ⌘ click or a ⇧ click, and press Combine. The panel takes files and not a folder.

2. Switch the form to CSV files

The Combine Files form opens with the Combine popup on Concatenate text files. Change it to Append CSV files with one schema. The Separator and Line endings popups dim, because they belong to text files, and the two CSV checkboxes become available. Sort the files by name is on at the start and orders the names the way Finder does, so part-2.csv comes before part-10.csv. The list at the bottom of the form follows that checkbox and shows the order in which the files will join. It shows the first twelve names and counts the rest. Under the list, the form names every file that is not UTF-8 with the encoding it will be read in, on a line such as Read as Windows-1252 and written as UTF-8: sales-2026-03.csv.

The Combine Files form with the Combine popup on Concatenate text files, the Separator and Line endings popups, three checkboxes and the list of the two chosen files

The Combine Files form as it opens, before the Combine popup is changed to Append CSV files with one schema.

3. Set the header row and the source column

The files have a header row (kept once, from the first file) is on at the start. Caxton writes the first row of the first file once, as the header. The first row of a later file is left out when it is that same header, compared without regard to upper and lower case and to the spaces around the names. A first row that is anything else is kept as a row of data, so a file with no header row keeps its first row, and the Schema Differences report in step 4 counts the files whose first row was kept. Turn the checkbox off when none of the files has a header row, because with it on the first row of the first file is written as the header.

Add a source column with each file's name puts a new first column in front of every row. Its header is source, and its value is the name of the file that the row came from, with the extension.

4. Read what differs before anything is written

Press Combine. Caxton reads the start of each file, finds its delimiter and its first row, and compares both with the first file in the list. When every file agrees, the combine starts. When one does not, a sheet named Schema Differences opens, and at that point nothing has been written. Each file that differs gets a line with the reason:

  • A different column count, shown as sales-2026-02.csv: 4 columns, the first file has 3.
  • Header names that the first file has and this one lacks, or the reverse, shown as missing note and extra discount.
  • The same names in a different sequence, shown as the same columns in another order.
  • A file that could not be read as a table, shown as no delimiter recognized.

Cancel stops there. Combine Anyway goes ahead by position: every row is written as it is, and Caxton does not reorder, rename or pad the columns. With the header checkbox on, a file whose first row is not the first file's header keeps that row as data, and that includes a header with other names or another order. The report counts those files. The comparison covers the first row of each file and not every row, and it compares header names only while the header checkbox is on. Each first row is read in the encoding of its own file.

5. Know what Caxton writes

Each file is read with its own delimiter, which Caxton detects among comma, tab, pipe and semicolon. Every row is then written with the delimiter of the first file, and a field that contains that delimiter, a quotation mark or a line break is quoted. A semicolon file whose values contain commas therefore joins a comma file without a shifted column, and a line break inside a quoted field stays inside its row. Rows are read where the grid reads them, so a quotation mark in the middle of a value, such as an inch mark, does not join two rows. A file in which no delimiter is recognized is skipped and named in the closing banner. When that file is the first one, nothing is written.

The result is UTF-8. Caxton reads each file in its own encoding, the one it would find on opening that file, and an encoding set for the file's name in Edit ▸ File Pattern Rules… counts as it does at open. A file in another encoding, such as Windows-1252 or UTF-16, therefore needs no conversion first, and the form names it under the list, as step 2 describes. A byte order mark at the start of a file is dropped.

6. Save the new document

Caxton streams the rows to a new document and opens it under the first file's name with (combined) after it. A status bar banner reports how many rows came from how many files. The document is untitled, so ⌘S asks for a name and a place, and the files you combined are unchanged.

How do I join plain text files into one?

For files that are not tables, such as logs, notes or the parts of a split file, cat is the right free tool and the command is the one shown earlier. It puts nothing between the files, and it does not add a line break after a file that lacks one.

In Caxton the same form does it with the Combine popup left on Concatenate text files, and it is Caxton Pro as well. Two popups set the details. Separator offers No separator, A blank line between files and A line naming each file, which writes a line with the file's name ahead of every file after the first. Line endings offers Keep each file's line endings, LF and CRLF, and the last two rewrite every line ending in the result to the one you chose. A file that does not end with a line break gets one, so the next file starts on a line of its own. A byte order mark at the start of a later file is dropped. Each file is read in its own encoding and the result is UTF-8, so text files in different encodings join without a conversion first. LF and CRLF line endings have their own guide.

Which approach fits which job?

The jobFree in TerminalIn Caxton
The files have no header row, or they are the parts of a split filecat joins them exactly as they areCombine Files with Concatenate text files joins them and adds a missing final line break
The files share their columns and each one starts with the headerThe awk rule keeps the first header and drops the restAppend CSV files with one schema keeps the header once
Each row should name the file it came fromcsvstack --filenames or DuckDB with filename = true adds the columnAdd a source column with each file's name adds it as the first column
The columns are in different orders or have different namescsvstack handles them, and so does DuckDB with union_by_name = true, and either is the better choice hereThe Schema Differences report lists the file, and Caxton does not realign it
One file uses another delimiterConvert that file first, because cat and awk copy it as it isEach file's delimiter is detected, and every row is written with the first file's delimiter
One file uses another encodingiconv converts it to UTF-8 firstEach file is read in its own encoding, the result is UTF-8, and the form names the files that are not UTF-8
The same files have to be combined every nightA script around any of these commands is the right toolCombine Files is a command you run by hand, so script this job

When the combined file is too large for the program that has to read it next, split the large CSV into parts again. When you need somewhere to look over the result, CSV editors for Mac compares the options by file size. When one file shows é where an accent should be, fix the encoding before you combine.

Choose the files, switch the form to Append CSV files with one schema, and read the Schema Differences report before anything is written.

Download Caxton for Free

7-day free trial of Caxton Pro, every feature, no credit card required. After it, Caxton Free keeps opening, searching and filtering at any size, and you can edit and save files up to 10 MB as text.

Frequently asked questions

How do I merge CSVs with different column orders?

Use a tool that matches columns by header name and not by position. The csvkit changelog records that csvstack handles files with columns in different orders or with different names, and DuckDB's read_csv takes union_by_name = true, which its documentation describes as aligning columns from different files by column name instead of position. cat, awk and Combine Files in Caxton all append by position. Caxton lists such a file in its Schema Differences report, as the same columns in another order, before anything is written, and it does not reorder the columns.

How do I know which file each row came from?

Add a column that holds the file name while you combine. csvstack --filenames uses the filename of each input file as its grouping value and adds it as a new column, and DuckDB's read_csv with filename = true adds a filename column that holds the path of each file. In Caxton, turn on Add a source column with each file's name in the Combine Files form, and every row starts with a column named source that holds the name of its file.

What if one file uses semicolons?

cat and awk copy lines as they are, so the semicolon file stays semicolon-separated inside the result and its rows no longer split into the same columns as the others. Convert that file to the delimiter of the others first, or use a tool that parses each file. In Caxton, Append CSV files with one schema detects the delimiter of every file on its own, whether comma, tab, pipe or semicolon, and writes every row with the first file's delimiter, quoting any field that contains it.

Can I combine files that are too large for Excel?

Yes. Microsoft documents the worksheet size as 1,048,576 rows by 16,384 columns, and none of the tools on this page works inside a worksheet. cat and awk read the files in sequence and write as they go. Combine Files in Caxton, a Caxton Pro command, reads each file from disk in pieces and streams the rows to a new document, so the result can hold far more rows than a spreadsheet, and Caxton opens it at any size.

Sources