I have an input CSV file, ttt.csv, which is comma delimited, each field may include double quote and comma:
Here is the contents of ttt.csv:
"CN=Bar\\,Alex,OU=Users,OU=Headquarters,DC=CORP",Bar,Alex,"Barziza,Alex",BARAAA,[email protected]
"CN=Boo\\,Ryan,OU=Users,OU=Headquarters,DC=CORP",Boo,Ryan,"Boo,Ryan",BABBBB,[email protected]
I would need to loop this file, for each line, I would need to get each of the 6 values and create my SQL insert statement to database.
In my case for Line 2 I would need to get:
Value1= CN=Bar\\,Alex,OU=Users,OU=Headquarters,DC=CORP
Value2= Boo
Value3= Ryan
Value4= Boo,Ryan
Value5= BABBBB
Value6= [email protected]
I used delimiter which includes double quotes and it does not seems working:
set str2="CN=Bar\\,Alex,OU=Users,OU=Headquarters,DC=CORP",Bar,Alex,"Barziza,Alex",BARAAA,[email protected]
echo %str2%
for /f "tokens=1 delims=(,")" %%a in ("!str2!") do ( set newstr2=%%a )
echo !newstr2!
forloop without the/fswitch and delims.