BurntSushi / xsv

A fast CSV command line toolkit written in Rust.
The Unlicense
10.29k stars 317 forks source link

Escaping not allowed characters in header #264

Closed verajosemanuel closed 3 years ago

verajosemanuel commented 3 years ago

Found solution here: https://github.com/BurntSushi/xsv/issues/251

I have a lot of csv to process with same header. My issue is that some column names are hyphen separated as here:

customer-name,customer-id,customer-account..... I am unable to process it with XSV as all I get is:


xsv input my.csv | xsv select customer-name,customer-id
customer  does not exist as a named header in the given CSV data.

xsv input my.csv | xsv select "customer-name","customer-id"
customer  does not exist as a named header in the given CSV data.

is there any way to force reading the header properly (not involving header rewriting) ?

Regards

BurntSushi commented 3 years ago

As documented in xsv select -h, you need to quote the field names. The - character indicates a range of fields. For example:

$ xsv select '"customer-name","customer-id"' my.csv
customer-name,customer-id
foo,bar