Merge CSV Files with Different Column Names Without Losing Records
A practical checklist for mapping mismatched CSV headers, selecting duplicate keys and checking the merged file.
What is the problem?
CSV files from different sources often label the same field differently, such as 'phone' versus 'mobile'. Appending rows without a shared schema can put unrelated data in the same column. Decide what each column means and which records count as duplicates before merging.
Step-by-step solution
Inspect every header and a few actual records
Keep the source files untouched and compare their header rows with representative records. Check whether similarly named fields contain the same kind of data; a date field with timestamps should not silently be treated as a date-only field.
Define one output schema and map columns deliberately
Write the target column names, then map source fields to them only when their meaning matches. Decide whether an absent field should become a blank cell or whether the source needs correction before inclusion.
Review duplicates and verify the exported CSV
Pick a defensible duplicate key before deleting anything. Compare the output with source records for encoding, header order, dates, leading zeros in identifiers and fields that unexpectedly became blank.
Alternative method
With a small number of files, you can import them into a spreadsheet, align the columns manually and copy rows into a new sheet. Watch for automatic type conversions.
Known limitations
Similar-looking names can refer to different data. Verify long identifiers, leading zeros, separators, encodings and ambiguous duplicate matches yourself.
Frequently asked questions
No. A shared name does not establish that two rows represent the same person. Compare additional identifying fields and the original records before removing either row.