xsv
xsv copied to clipboard
Any way to handle a comma in a header?
For example given the following CSV data (from a survey)
Name,"Do you consider yourself to have a disability, impairment or long-term condition?"
Ben,Yes
Phil,No
This command fails:
.\xsv.exe select Name,"Do you consider yourself to have a disability, impairment or long-term condition?" test.csv
This works for me on MS Windows (quoting 4 times):
.\xsv.exe select Name,""""Do you consider yourself to have a disability, impairment or long-term condition?"""" test.csv
You need to escape the double quotes like so,
hbina@akarin ~/D/test-xsv> cat select_test.csv
Name,"Stringly header"
Ben,Yes
Phil,No⏎
hbina@akarin ~/D/test-xsv> xsv select Name,"\"Stringly header\"" select_test.csv
Name,Stringly header
Ben,Yes
Phil,No