How to Merge CSV Files
Updated
Merging CSV files means combining data from two or more files into one. Whether you're consolidating monthly exports or enriching contacts with data from a second source, the method depends on whether you're appending (stacking rows) or joining (matching rows by a key).
Append vs join: pick the right merge type
| Merge type | When to use | Example |
|---|---|---|
| Append (stack) | Same columns, different rows | Combining January, February and March export files into one file |
| Join (match) | Different columns, matching rows | Adding company size from a second file to your contacts by matching on email |
Getting this wrong is the most common merge mistake. Appending files with different columns creates blank cells and misaligned data. Joining without a reliable key duplicates or drops rows.
Appending in Excel: the manual way
- Open the first file in Excel.
- Open each additional file, select all data rows (not the header), copy and paste them below the last row of the first file.
- Check that columns align — the same field must be in the same column across all files.
- Remove any duplicate header rows that were accidentally included.
This works for two or three small files. For dozens of monthly files or files with mismatched columns, it becomes impractical.
Joining in Excel with VLOOKUP
- Put the main file in Sheet1 and the file with additional columns in Sheet2.
- In Sheet1, add a new column and enter =VLOOKUP(A2,Sheet2!A:D,2,FALSE) where A is the key column and 2 is the column number you want to pull from Sheet2.
- Repeat for each column you want to bring in, changing the column number.
- Fill the formulas down and paste as values to remove the formula dependency.
VLOOKUP returns the first match only, so duplicate keys in Sheet2 will silently use the wrong row. INDEX/MATCH is more flexible but equally prone to this problem.
Common merge pitfalls
- Column mismatch — files from different months may have added, removed or renamed columns. Always check headers before appending.
- Duplicate keys — if the key column has duplicates in either file, a join will silently match the wrong rows. Deduplicate first.
- Encoding differences — one file in UTF-8 and another in Windows-1252 will produce garbled characters when combined. Convert both to the same encoding first.
- Data type inconsistency — one file stores phone numbers as text with leading zeros, another as numbers without them. Standardise before merging.
- Missing key values — rows with a blank key column won't match anything and will be silently dropped in a join, or duplicated in an outer join.
When you have many files
If you regularly merge more than a handful of files — weekly exports, regional sales data, multi-team reports — Excel's manual approach doesn't scale. Power Query (Data → Get Data → Combine Queries) can automate multi-file appends, but setting it up requires understanding the M query language and handling schema differences between files.
Merge with TheSpreadFix
TheSpreadFix lets you upload multiple CSV files and choose between append and join. For appends, it aligns columns by header name even when the order differs, and flags columns that exist in some files but not others. For joins, it matches rows on a key column you select and lets you choose which columns to bring in. The merged file is processed in your browser and ready to download.
Frequently asked questions
What happens when the files have different columns?
For an append, rows from a file that is missing a column will have blank values in that column. TheSpreadFix flags these mismatches so you can decide whether to proceed. In Excel, you need to add the missing columns manually.
Can I merge more than two files at once?
Yes. For appends, you can stack any number of files. For joins, you typically join two at a time — main file plus enrichment file — and repeat if you have multiple sources.