mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
Add uniq command (#1132)
* start playing with ways to use the uniq command * WIP * Got uniq working, but still need to figure out args issue and add tests * Add some tests for uniq * fmt * remove commented out code * Add documentation and some additional tests showing uniq values and rows. Also removed args TODO * add changes that didn't get committed * whoops, I didn't save the docs correctly... * fmt * Add a test for uniq with nested json * Add another test * Fix unique-ness when json keys are out of order and make the test json more complicated
This commit is contained in:
committed by
Jonathan Turner
parent
dba82ac530
commit
f37f29b441
36
docs/commands/uniq.rs
Normal file
36
docs/commands/uniq.rs
Normal file
@ -0,0 +1,36 @@
|
||||
# uniq
|
||||
|
||||
Returns unique rows or values from a dataset.
|
||||
|
||||
## Examples
|
||||
|
||||
Given a file `test.csv`
|
||||
|
||||
```
|
||||
first_name,last_name,rusty_at,type
|
||||
Andrés,Robalino,10/11/2013,A
|
||||
Andrés,Robalino,10/11/2013,A
|
||||
Jonathan,Turner,10/12/2013,B
|
||||
Yehuda,Katz,10/11/2013,A
|
||||
```
|
||||
|
||||
```
|
||||
> `open test.csv | uniq`
|
||||
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━
|
||||
# │ first_name │ last_name │ rusty_at │ type
|
||||
───┼────────────┼───────────┼────────────┼──────
|
||||
0 │ Andrés │ Robalino │ 10/11/2013 │ A
|
||||
1 │ Jonathan │ Turner │ 10/12/2013 │ B
|
||||
2 │ Yehuda │ Katz │ 10/11/2013 │ A
|
||||
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━
|
||||
```
|
||||
|
||||
```
|
||||
> `open test.csv | get type | uniq`
|
||||
━━━┯━━━━━━━━━
|
||||
# │ <value>
|
||||
───┼─────────
|
||||
0 │ A
|
||||
1 │ B
|
||||
━━━┷━━━━━━━━━
|
||||
```
|
Reference in New Issue
Block a user