Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, I'm looking for help how to merge or copy all CSV files without the first row 'header'. I want this on Dos command (*.bat) file if possible.
So csv look like:
cvs1:
A,B,C,D
1,2,3,4
csv2:
A,B,C,D
5,6,7,8result i want is:
all.cvs:
A, B, C, D
1, 2, 3, 4
5, 6, 7, 8
Thanks in advance!

You would have better luck with a posting in the programming since this is not a xp issue.
Moderator please delete.

Difficult at best in DOS. In XP try this:
==================================
@echo off & setLocal EnableDELAYedExpansionif exist all.csv del all.csv
set /p head=<1.csv
> newfile echo !head!for /f "tokens=* delims= " %%a in ('dir/b *.csv') do (
for /f "skip=1 tokens=* delims= " %%i in (%%a) do (
>> newfile echo %%i
)
)
ren newfile all.csv
=====================================
Helping others achieve escape felicityM2

Mechanix2go... I am sure your help is appreciated but there are forums devoted to various aspects of computing and it is better that posters use them. This forum is being beseiged by posters looking for help with batch, bat and other programming issues.
Home Page http://ewen.uuuq.com/

Thanks Mechanix2Go
U r the best! one thing missing is the header I want to keep the same header or column name for all CSV files.i.e.
csv1:
A, B, C, D
1, 2, 3, 4csv2:
A, B, C, D
5, 6, 7, 8
csv3:
A, B, C, D
11,12,13,
results should be:
all.csv:
A, B, C, D
1, 2, 3, 4
5, 6, 7, 8
11,12,13,

When I run it I get the header.
=====================================
Helping others achieve escape felicityM2

I have another challenge task:
2 csv's with the same column contents just different name and I have another 2 csv's with the same columns...
i.e
abc_1.csv & def_1.csv --> results: abcdef.csv
gof_1.csv & yol_1.csv --> results: gofyol.csvabc_1.csv contains:
A, B, C
1,2,3
def_1.csv contains:
A, B, C
4, 5, 6
results: abcdef.csv
A, B, C
1,2,3
4,5,6gof_1.csv contains:
AA,BB,CC
11,22,33
yol_1.csv contains:
AA,BB,CC
44, 55, 66
results: gofyol.csv
AA, BB, CC
11,22,33
44,55,66So basically, I want 1 batch script to do this instead.

If it's going to do selective merging, as distinct from merging all CSVs in the folder, it will need to prompt for what to merge with what.
That's your homework assignment.
=====================================
Helping others achieve escape felicityM2

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |