BurntSushi / xsv

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

`xsv join --cross` shouldn't require columns to match #339

Open scooter-dangle opened 5 months ago

scooter-dangle commented 5 months ago

I assumed based on the help that I could use xsv join --cross - some-data.csv - (echo new_field\n0 | psub) (in fish, hence the psub for process substitution…same issue if I write to a file) to add an entry of 0 for new_field to all the rows in some-data.csv, since a cross join is doing a cartesian product rather than matching up specific columns.

xsv however complains if the number of columns specified don't match or if the columns specified are not the same name, even though that's not required for a cartesian product.

scooter-dangle commented 5 months ago

Ah…I see I can just supply 1 as the columns for both inputs so that it 'joins' on the first column (i.e., xsv join --cross 1 some-data.csv 1 (echo new_field\n0 | psub) works). Is that actually being used by the logic or is it just required for the CLI args to be validated?

If it's the latter, I might open a PR to mention that usage note in the CLI doc string.