Saturday, June 13, 2026

How to consolidate CSV files

If there are a number of CSV files that have the same data structure, they can be consolidated using a CMD command. If all CSV files have identical headers, combining them into a single CSV file is very easy.

Steps

  1. Put all your CSV files into one folder.
  2. Open cmd.exe in that folder:
    • Open the folder in File Explorer.
    • Click the address bar.
    • Type cmd and press Enter.
    • A Command Prompt window will open in that folder.
  3. Type the following command and press Enter:

copy *.csv Combined.csv

This command merges all CSV files in the current folder into a file named Combined.csv.

Important Note

If every CSV file contains the same header row, the above command will also copy the headers repeatedly. To keep only one header row:

  • Create the combined file using the first CSV file.
  • Append the remaining files without headers, or remove duplicate header rows afterward using Excel, Power Query, or a script.

Example:

Files:

Sales1.csv

Sales2.csv

Sales3.csv

Command:

copy *.csv AllSales.csv

Result:

AllSales.csv

You can open the consolidated CSV file in Excel or any text editor to verify the merged data.

No comments:

Post a Comment

Hot Topics