Home > database >  How to create one string from values from CSV file in bat file?
How to create one string from values from CSV file in bat file?

Time:03-31

I have a csv file and I need to read its values to one string.

This is what I have for now:

setLocal EnableDelayedExpansion
set FULL_STR=""
for /f "usebackq tokens=1-3 delims=," %%a in ("%CSV_PATH%") do (
    set !FULL_STR!=!FULL_STR!%%a%%b%%c
)
echo !FULL_STR!      //returns ""

Could anyone help me to do it?

CodePudding user response:

set FULL_STR=""

sets FULL_STR to "".

set "FULL_STR="

sets FULL_STR to empty.

set !FULL_STR!=!FULL_STR!%%a%%b%%c

sets a variable named [the current contents of FULL_STR] to [the current contents of FULL_STR][the two fields from the file]

set "FULL_STR=!FULL_STR!%%a%%b%%c"

sets the variable FULL_STR to [the current contents ofFULL_STR][the two fields from the file]

  • Related