Merge CSV files in a folder

Post Reply
KaesDS
Newbie
Posts: 12
Joined: Thu Sep 22, 2016 10:33 am

Merge CSV files in a folder

Post by KaesDS »

Hi guys,

is there a (powershell?) script to merge all CSV files in a folder that works for a job folder in Switch?
In my case the CSV files have no headers.

SwitchJobFolder "customername" containing customername.csv, customername_1.csv, customername_2.csv etc. -> merge to "customername.csv". (Like the "Merge PDF" Tool in Switch!)

I would be grateful for any suggestion. :idea:
sander
Advanced member
Posts: 274
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: Merge CSV files in a folder

Post by sander »

Laziest approach I can think of:
"copy *.csv combined.csv" via command prompt @ Windows.

Image
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Re: Merge CSV files in a folder

Post by dkelly »

If you need a more advanced CSV merge solution contact sales@apago.com for information about our collection of CSV utilities for Switch.
dk_jad
Newbie
Posts: 12
Joined: Wed Jun 06, 2018 12:26 pm

Re: Merge CSV files in a folder

Post by dk_jad »

the command prompt approach is really simple and efficient, but only if you dont have headers in each csv file. AFAIK there is a command to strip the first line of a file, but i can't remember it. But if you have a file with only the headers, you could combine the csv's without header first, and then add the header in a second copy command. This way you can control that the header comes first(it copies alphabetically) because you define the output .csv filename in the first copy command.
KaesDS
Newbie
Posts: 12
Joined: Thu Sep 22, 2016 10:33 am

Re: Merge CSV files in a folder

Post by KaesDS »

sander wrote: Fri Jul 13, 2018 12:02 pm Laziest approach I can think of:
"copy *.csv combined.csv" via command prompt @ Windows.

Image
Thanks sander! :) This was my first attempt, but Switch would have to pass the path of the job folder to the .bat file. At the same time I should be able to pass the output path.

Maybe something like "copy %1/*.csv %2/merged.csv"?
Post Reply