The best free ways to merge CSV files
By the Analistable team · Updated · 5 min read
The best free CSV merger depends on your files. For files with identical columns, a one-line command is fastest. For files with different columns or encodings, use Excel's Power Query or Python, which match headers by name. For a quick merge without installing anything, use a browser tool that runs locally so your data isn't uploaded.
Part of our guide: How to merge CSV files into one
What to look for
- One header row in the output, not one per file.
- Columns matched by name, so reordered or extra columns don't scramble the data.
- A source column showing which file each row came from.
- Encoding and delimiter control for exports from different systems.
- Privacy: whether files are uploaded to a server.
- Size: how many rows it can handle.
Comparison
| Option | One header | Match by name | Source column | Large files | Data uploaded |
|---|---|---|---|---|---|
| Windows `copy *.csv` | No | No | No | Yes | No |
| Mac/Linux `awk` | Yes | No | With a tweak | Yes | No |
| PowerShell Import-Csv/Export-Csv | Yes | Partly | With a tweak | Medium | No |
| csvkit `csvstack` | Yes | Yes | Yes (-n) | Medium | No |
| Python pandas | Yes | Yes | Yes | Yes | No |
| Excel Power Query | Yes | Yes | Yes | Up to Excel's row limit (more in Data Model) | No |
| Google Sheets (import + VSTACK) | Manual | No | Manual | 10 million cells per file | Stored in Google Drive |
| Typical online merger | Usually | Varies | Varies | Upload limits | Yes |
| Analistable CSV combiner | Yes | Yes | Yes | Limited by browser memory | No |
Command line
Fastest for many files with identical columns. Mac and Linux: see combining CSV files on a Mac. Windows Command Prompt's copy *.csv all.csv repeats every header; PowerShell does better:
Get-ChildItem *.csv | ForEach-Object { Import-Csv $_ } | Export-Csv ..\combined.csv -NoTypeInformationPowerShell uses the first file's columns for the output, so columns that only appear in later files are dropped.
csvkit and Python
csvstack -n source --filenames *.csv > combined.csv (csvkit, installed with pip install csvkit) stacks files and adds a source column. In Python, pd.concat(map(pd.read_csv, files)) matches columns by name. See merging data in pandas.
Excel and Google Sheets
Excel's Power Query is the most capable free option if you already have Excel: it handles encodings, delimiters and different columns, and refreshes. Details: combining CSV files in Excel. Google Sheets has no folder import, so you import each file and stack them with VSTACK — fine for a handful of files.
Online tools
Convenient, but most upload your files. Before using one with customer or financial data, check it — our guide to merging without uploading shows how in a minute. The Analistable CSV merger processes files in your browser.
Test files: how each option handles the hard cases
The differences between options only appear with awkward files. Three small test files show them clearly:
| File | Header | Quirk |
|---|---|---|
| north.csv | date,sku,units | Plain |
| south.csv | sku,date,units | Same columns, different order |
| west.csv | date,sku,units,channel | An extra column |
| Option | south.csv rows | channel column |
|---|---|---|
| awk / copy | SKU lands under date (columns misaligned) | Extra value with no header |
| PowerShell Import-Csv | Aligned by name | Dropped (first file's columns are used) |
| csvkit csvstack | Aligned by name | Kept; blank for other files |
| pandas concat | Aligned by name | Kept; NaN for other files |
| Power Query From Folder | Aligned by name if the combine step expands all columns | Kept only if included in the expand step |
If your exports always come from the same system with the same header, the simple commands are fine. If they don't, choose an option that matches by name.
pandas in more detail
import glob
import pandas as pd
frames = []
for path in sorted(glob.glob("exports/*.csv")):
df = pd.read_csv(path, dtype=str, encoding="utf-8")
df["source"] = path
frames.append(df)
combined = pd.concat(frames, ignore_index=True)
combined.to_csv("combined.csv", index=False)
print(len(combined), "rows")dtype=str keeps leading zeros and long IDs exactly as they were. Columns are aligned by name, and a column that exists in only some files is filled with empty values elsewhere. For files too big for memory, pandas can read in chunks, or see merging large CSV files.
Privacy and size: the deciding factors
Every local option — command line, Power Query, Python, csvkit and browser tools that process files on your device — keeps the data on your computer. Google Sheets stores the imported data in your Drive, which is fine for many teams but not for every data policy. Typical online mergers upload files to a server, and free tiers often cap file size or number of files. On size, command-line tools stream line by line and handle files of many gigabytes; pandas is limited by memory; Excel sheets stop at 1,048,576 rows; browser tools are limited by the memory the browser allows.
Recommendation by situation
| Situation | Choose |
|---|---|
| Same header in every file, any size | awk (Mac/Linux) or PowerShell (Windows) |
| Different column orders or extra columns | csvkit, pandas or Power Query |
| Monthly job, non-technical team | Power Query From Folder with Refresh All |
| Very large files | Command line, or a database such as DuckDB or SQLite |
| Quick one-off, no installs, sensitive data | A browser tool that doesn't upload |
Checklist before trusting a merged file
- Row count equals the sum of the input files' data rows.
- Exactly one header row: search the merged data for the header text.
- IDs and postcodes kept their leading zeros.
- Accented characters display correctly (encoding).
- Every row has a source value, so problems can be traced back to a file.
For combining CSV exports with Excel or Google Sheets data rather than just with each other, see combining data from multiple sources.
Merging CSVs with a database
For files in the hundreds of megabytes or larger, a database engine merges and queries them without loading everything into a spreadsheet. DuckDB, for example, can read a whole folder of CSV files in one SQL statement and align columns by name:
-- DuckDB
COPY (
SELECT * FROM read_csv_auto('exports/*.csv', union_by_name = true, filename = true)
) TO 'combined.csv' (HEADER);union_by_name matches columns by header, and filename adds a column with each row's source file. SQLite can also do the job by importing each file into a table and running INSERT INTO … SELECT, but it needs one import per file. Both are free; neither needs a server.
Frequently asked questions
- What is the easiest free way to merge CSV files?
- A browser tool that keeps one header row is the easiest. For repeated merges, Excel's Power Query From Folder refreshes in one click.
- Can I merge CSV files with different columns for free?
- Yes, with Power Query, pandas, csvkit or a browser tool that matches columns by header name.
- Is it safe to merge CSV files online?
- Only if the tool doesn't upload your data, or the data isn't sensitive. Check the browser's Network tab while adding a test file.
- Which free option handles the biggest CSV files?
- Command-line tools and databases such as DuckDB, because they stream data from disk instead of loading it all into a spreadsheet or browser memory.
- Can Excel open the merged CSV if it has more than a million rows?
- Not on a worksheet, which stops at 1,048,576 rows. Load it through Power Query into the Data Model, or analyse it in a database or pandas.
- Do I need to install anything to merge CSV files for free?
- No. macOS and Linux include awk, Windows includes PowerShell, and Excel's Power Query is built into recent versions. Python, csvkit and DuckDB need installing; browser tools need nothing beyond a browser.