This is my batch script to read csv file and assigning values to batch variables. This script reads the file perfectly, but when it comes to the last line of csv file...the last line is executed twice. I am not getting the reason why the last line is read twice. Following is my batch code
@echo off
:: Set input file in _variable
Set _InputFile=%1
:: Store input line into different _variables
FOR /F "tokens=1-4* delims=," %%A IN (%_InputFile%) DO (
Set _var1=%%A
Set _var2=%%B
Set _var3=%%C
Set _var4=%%D
CALL :PROCESS
)
:PROCESS
IF "%_var1%"=="Application Name" echo FIRST LINE
IF "%_var1%"=="Transition Portal" echo %_var2%
IF "%_var1%"=="Coast" echo %_var2%
IF "%_var1%"=="TI" echo %_var2%
This is my csv file:
Application Name,Environment,Release No.,Revision No.
Transition Portal,Test,,
Coast,Dev,handle,0
TI,Prod,check,3
The output I get is:
FIRST LINE
Test
Dev
Prod
Prod
If you notice 'Prod' got printed two times. Can anyone please let me know why is the last line executed two times?