Oleg_08
Oleg_08

Reputation: 487

How to write to the second column in .CSV using batch script?

I'm trying to read a column of numbers from the .txt file and place them in the .csv in the second column.

How to define the second column in batch?

for /f "tokens=1 delims= " %%i in (issn.txt) do (
 >>"anzahl.csv" echo %%i

Upvotes: 0

Views: 1170

Answers (1)

user6811411
user6811411

Reputation:

This will create file New-Anzahl.csv which has empty col2's when number of entries in issn.txt is less than anzahl.csv count. Other way around issn.txt overhang is truncated.

@Echo Off & SetLocal EnableDelayedExpansion
Set "FileA=anzahl.csv"
Set "FileB=issn.txt"
<%FileB% (For /f "delims=" %%A in (%FileA%) Do (
    Set "B="&Set /P "B="
    Echo:%%A,!B!
)) >New-%FileA%

Upvotes: 2

Related Questions