My problem statement. I have 2 csv files. I want to merge first 2 rows of both files together become one.I run my code it seems like my second header is missing and the data append to 3rd row.
File A:
A B 1 2
File B:
C D 3 4
Expected result:
A B C D 1 2 3 4
My code:
@echo off
cd /d "C:\my csv directory"
set first=true
setlocal enabledelayedexpansion
(for %%x in (*.csv) do (
if !first!==true (
type "%%x"
echo.
set first=false
) ELSE (
more +1 "%%x"
)
))> c:\destination\newfile.csv
Fail result:
a,b 1,2 3,4
To merge columns from two files you can read two files in paralllel