what is the correct code to run a batch script if we want a specific data?
If the data looks like this
C,P,Non_Engaged
P,P1,Non_Engaged
P1,P2,Non_Engaged
P2,P3,MDM
Then the output should be like this
C, P3, MDM
echo off
setlocal enabledelayedexpansion set “input_value=%~1”
rem set /p input_value-Enter the value to search for: rem set “input_value=some.
_value” REM Replace with your actual input value
set “csv_file=C:UserspchikhaleDownloadsworkdata2.csv”
REM Replace with the actual path to your CSV file
: search_100p
for /f “tokens=1,2,3 delims=,” %%a in (%sv_file%) do (
set “out_port=%%c”
echo %%c
exit /b
) else (
echo %%a %%b %%c
set “input_value=%%b”
goto search_loop
set “out_port=Not_Found”
echo Not_Found
Tried this code
Pallavi Chikhale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.