A tool for joining CSV data on command line.
Dual-licensed under MIT or unlicense
Add this to your Cargo.toml
:
toml
[dependencies]
rjoin = "0.1.0"
add this to your crate root:
rust
extern crate rjoin;
The binary name for rjoin
is rj
.
bash
$ cargo install rjoin
(don't forget to add $HOME/.cargo/bin
to your path).
rjoin
?rjoin
?cut
or awk
.tr
utility.Let's suppose we have the following data:
bash
$ cat left
color,blue
color,green
color,red
shape,circle
shape,square
bash
$ cat right
altitude,low
altitude,high
color,orange
color,purple
To get the lines with the common key:
bash
$ rj left right
color,blue,orange
color,blue,purple
color,green,orange
color,green,purple
color,red,orange
color,red,purple
Some comments:
--key/-k
option (even per file).
rjoin
supports multiple fields as the key, but the number of key fields in both files must be equal.--show-left/-l
, --show-right/-r
or --show-both/-b
. Note however, if you use any of these options, the default behavior
of showing matches of both files is reset and must be made explicit if desired by adding -b
. To get the lines with the unmatched key in both files:
bash
$ rj -lr left right
altitude,low
altitude,high
shape,circle
shape,square
Any kind of contribution (e.g. comment, suggestion, question, bug report and pull request) is welcome.
A big thanks to BurntSushi for his excellent work.