Lanternhill Studio · Bank CSV Categorizer

How to Combine Multiple CSV Files into One

Monthly bank exports and report downloads often come as separate CSVs. Here are three reliable ways to stack them into one file. All of them assume the files share the same columns in the same order. If they don't, use Power Query or our tool, which match columns by header.

1. Excel Power Query (Excel 2016 and later, Microsoft 365)

  1. Put all the CSV files in one folder, and nothing else.
  2. In Excel, go to Data → Get Data → From File → From Folder and pick the folder.
  3. In the preview window click Combine → Combine & Load (or Combine & Transform Data to clean it up first).
  4. Choose the sample file and confirm the delimiter, then click OK.

Excel loads one table with a Source.Name column showing which file each row came from. Headers are used once, not repeated. When you add more files to the folder, Data → Refresh All picks them up. Power Query matches columns by name, so files with columns in a different order still line up.

2. Command line

Open a terminal in the folder with the CSVs. These write the result one folder up so the output file isn't picked up as an input.

Windows (PowerShell)

Get-ChildItem *.csv | ForEach-Object { Import-Csv $_.FullName } | Export-Csv ..\combined.csv -NoTypeInformation

This keeps one header row. Export-Csv uses the columns of the first file, so all files need the same headers. It also puts quotes around every value, which Excel and Sheets read normally.

Mac or Linux (Terminal)

awk 'FNR==1 && NR!=1 {next} {print}' *.csv > ../combined.csv

It prints the first file whole and skips line 1 (the header) of every later file. A plain cat *.csv works too, but it repeats the header row from every file.

3. Google Sheets

Files imported as tabs in one spreadsheet

Import each CSV with File → Import → Upload → Insert new sheet(s), named e.g. Jan, Feb, Mar. On a new tab, stack them with an array literal, where the semicolon means "put below":

=QUERY({Jan!A2:D1000; Feb!A2:D1000; Mar!A2:D1000}, "select * where Col1 is not null", 0)

Make 1000 bigger if a tab has more rows. Put your headers in row 1 yourself and this formula in A2. Every range must have the same number of columns. QUERY drops the empty rows below your data in each range. In some locales the separator inside { } is different, so if you get a parse error check your spreadsheet's locale.

Data in separate spreadsheets

=QUERY({IMPORTRANGE("URL_of_file_1","Sheet1!A2:D1000"); IMPORTRANGE("URL_of_file_2","Sheet1!A2:D1000")}, "select * where Col1 is not null", 0)

Before this works, each IMPORTRANGE needs permission. Enter each one on its own in a cell once and click Allow access. Then use the combined formula. The result is live; File → Download → CSV saves it as one file.

Frequently asked questions

How do I combine CSV files in Excel?

Use Power Query (Excel 2016 and later): Data → Get Data → From File → From Folder, then Combine. It stacks every file in the folder into one table.

Can I merge CSV files without Excel?

Yes, on the command line, or by importing each file into Google Sheets and stacking them, or with our free in-browser Merge CSV Files tool.

What if the files have header rows?

Keep only the first file's header; remove the repeated header rows from the other files so they don't appear as data.

Skip the formulas: the free Merge CSV Files tool does this in your browser. Nothing is uploaded.

Want more than a quick fix?

Just starting out? Grab the free Starter Expense Tracker (pay what you want, $0 is fine).

Guides