I have a situation where I need to combine four CSV files into one CSV file. This is easy if i just wanted to add them one after the other, but I need to get them to be side by side in the CSV file. I know that all four files have the same number of entries (in the 1000 entry range). I have been working on the following code which works for small files but is extremely inefficient for long files. Is there any easier way to accomplish the same task?
@echo off
setlocal enabledelayedexpansion
Set R=1
Set T=1
Set Y=1
Set U=1
for /f %%a in (test1.txt) do (
set I=!R!
for /f %%b in (test2.txt) do (
set J=!T!
for /f %%c in (test3.txt) do (
set K=!Y!
for /f %%d in (test4.txt) do (
set L=!U!
If !I!==!J! If !J!==!K! If !K!==!L! echo %%a,%%b,%%c,%%d >> TestComplete.txt
Set /a U=U+1
)
Set U=1
Set /a Y=Y+1
)
Set Y=1
Set /a T=T+1
)
Set T=1
Set /a R=R+1
)
Note: I know that the code I have pasted in is using .txt files and not .csv files. I assume what will work for one will work for the other.
Again, The above code seems to work great as long as the files are small. I have trouble (of course) when the files (in this case test1.txt) have around 1000 lines of text.