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.
Merge CSV files in a folder
Re: Merge CSV files in a folder
Laziest approach I can think of:
"copy *.csv combined.csv" via command prompt @ Windows.
"copy *.csv combined.csv" via command prompt @ Windows.
-
- TOP CONTRIBUTOR
- Posts: 658
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Re: Merge CSV files in a folder
If you need a more advanced CSV merge solution contact sales@apago.com for information about our collection of CSV utilities for Switch.
Re: Merge CSV files in a folder
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.
Re: Merge CSV files in a folder
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"?