I have a csv
file such as below
Name,Test User1
Name2,TstUser Two
Name3,Test User Three
I need to extract the Test User1
in to a Variable in a batch file,and other variables similarly to different variables.
I have a csv
file such as below
Name,Test User1
Name2,TstUser Two
Name3,Test User Three
I need to extract the Test User1
in to a Variable in a batch file,and other variables similarly to different variables.
@echo off
setlocal
for /f "tokens=1,* delims=," %%a in (file.csv) do set "_%%a=%%b"
echo your variables are:
set_
Output with your example data:
your variables are:
_Name=Test User1
_Name2=TstUser Two
_Name3=Test User Three
Edit to get a single line/variable only:
@echo off
setlocal
for /f "tokens=2 delims=," %%a in ('type file.csv^|findstr /bi "Name,"') do set "Name=%%a"
echo %Name%