BurntSushi / xsv

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

Feature request: A new join type `--left-anti` #281

Open hktonylee opened 2 years ago

hktonylee commented 2 years ago

I would suggest to add a new join type left-anti which has same semantic as what Spark does. Basically this join type will return the left table when the key is not found in the right table.

Here is an example:

Suppose we have a.csv

name,quantity
apple,10
orange,50

and b.csv

name,color
apple,10

After running this proposed command: xsv join name a.csv name b.csv --left-anti, it will output

name,quantity
orange,50

Because orange is not found in b.csv. Please also note that the output will have a.csv columns only.

I know this is same as the following combination, but it would be great it this feature is built in the xsv.

xsv join name a.csv name b.csv --left \
  | xsv search -s 'name[1]' '^$' \
  | xsv select 'name,quantity'

Any thoughts?

mailsanchu commented 2 years ago

I think this would be a nice feature. I have a use case for this