I am trying to sort the values of a CSV file but as some values in the CSV files are covered with double quotes and comma. So the resulted output is not what I am expecting. Please find the script, input file, output file and my expected output file. Please suggest me the change that is required in my script to get the desired output.
My Code:
Code: Select all
@echo off
for /f "tokens=1,2,3,4,5,6 delims=," %%a in (test.csv) do (
echo "%%a","%%b","%%c","new_addition","%%d","%%e","%%f">>test_out.csv
)
Input File:
Code: Select all
sam,austraila,richard,AUS,sydney,"Associate, consultant"
shaswat,"san, matio",don,IN,"US, City",SE
Output file that is generated from the above code:
Code: Select all
""Associate","sam","sydney","LINE_TEST","austraila","AUS","richard"
""US","shaswat","IN","LINE_TEST",""san","don"," matio""
Desired output file:
Code: Select all
"Associate, consultant","sam","sydney","LINE_TEST","austraila","AUS","richard"
"SE","shaswat","US, City","LINE_TEST","san, matio","IN","don"
Thanks a lot for your help and time.
Regards,
Shaswat