CSV guide

How to Merge Multiple CSV Files with Different Columns

Appending raw lines works only when every file has identical headers and no valid field contains a newline. A safer merge parses each source independently and aligns its cells before writing the combined file.

Open the CSV file merger

Try this guide’s example here

Worked example: reconcile two regional exports

The East export includes a total; the West export includes a status and puts region before account_id. The job is to combine all four records while retaining both optional columns and identifying the original file. These are synthetic files you can run in the example below.

1. Inspect each source before choosing a merge mode

Download merge-east.csv: two records, with account_id in the first column.

account_id,region,total
000184,east,52.20
000219,east,71.00

Download merge-west.csv: two records, with account_id in the second column.

region,account_id,status
west,000305,active
west,000402,pending

Do not rename status to total to make the headers match: the columns represent different information. A missing amount is not a zero amount. Keep the identifier as text when opening the result in a spreadsheet so that 000305 does not become 305.

2. Reproduce the incorrect alignment, then correct it

Choose Try sample below. With column-position alignment, the first West record is labelled account_id=west, region=000305 and total=active. Every row can have the expected number of cells and still be wrong. Compare meaning as well as shape.

Switch to By header — union all columns and enable Add source filename column. Union keeps both total and status. Intersection would discard both because neither occurs in every source. That is unsuitable for this job even though it also produces four records. The merger's mode reference shows the output of each alignment option.

3. Check this expected result

source_file,account_id,region,total,status
merge-east.csv,000184,east,52.20,
merge-east.csv,000219,east,71.00,
merge-west.csv,000305,west,,active
merge-west.csv,000402,west,,pending

The source column identifies where each record came from. The East records have empty status cells; the West records have empty total cells. Those blanks mean that the source did not supply that column. They do not establish whether a status is unknown, an amount is unpaid, or a value should be filled from another system.

4. Reconcile the export before using it

  • Count four data records, excluding the header. Check two East records and two West records using source_file.
  • Find 000305 and confirm region=west, status=active and an empty total. Check 000184 has region=east and total=52.20.
  • Reopen the downloaded file with the CSV viewer. Confirm the same five columns and four records, rather than trusting how a text editor displays commas.
  • Keep the source files until the destination accepts the result. A successful download proves that a file was written, not that the destination's required fields are satisfied.

When your own files do not match the example

If you get both Account_ID and account_id, standardize capitalization in the original headers and merge again. Leading and trailing header spaces are trimmed, but internal spaces and case remain significant. Give repeated or empty headers meaningful, unique names before name-based merging; otherwise the intended mapping is ambiguous.

Merging appends records; it does not join two customer records by ID or remove duplicates. If the same account appears in both sources, first decide whether those are separate events or duplicate records. Use duplicate removal only after deciding which columns identify a duplicate.

For notes containing embedded line breaks, count parsed records rather than physical lines. Validate malformed quotes or inconsistent row widths with the CSV validator before interpreting a row-count mismatch as missing business data. Do not replace every newline or comma in the source: both may be legitimate field content.

Step by step

  1. Choose all input files in one selection.
  2. Use header union when files may add columns, or intersection when only shared columns should remain.
  3. Enable the source filename column when the output needs provenance.
  4. Review missing values and diagnostics before downloading the merged CSV.

Check the result

  • Confirm that each output header appears once and that values from every input file land under the intended column.
  • Filter by the optional source filename column and compare a few records with each original file.
  • Review the final row count: it should normally equal the sum of data rows in all inputs unless a file was rejected.

Common pitfalls

  • Position-based alignment can put values under the wrong header when files use different column orders.
  • Header spelling and case must match; surrounding spaces are trimmed, but internal spaces remain significant for name-based alignment.
  • A multiline quoted value is one CSV record even though it occupies more than one physical line.

Try the example on this page

Choose Try sample to load this guide’s synthetic data. Adjust the settings, inspect the result and export it here. You can also choose your own file for local processing.

CSV export options
Drop a file, paste data, load a CORS-enabled URL, or try the sample.
Rows0
Columns0
EncodingAuto
DelimiterAuto
Issue groups0

Open a data file to start

The parser runs off the main thread. Once loaded, you can search, sort, validate, repair and export without an account.

Original samples: merge-east.csvmerge-west.csv

Check expected outcomes and file checksums

Related CSV guides

Privacy boundary

Files selected in the workbench are processed locally. A public URL is requested directly by the browser and must permit cross-origin access. No server proxy is used by the MVP.