2019-12-31 05:05:02 +01:00
|
|
|
# uniq
|
|
|
|
|
|
|
|
Returns unique rows or values from a dataset.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
Given a file `test.csv`
|
|
|
|
|
2020-06-23 20:21:47 +02:00
|
|
|
```csv
|
2019-12-31 05:05:02 +01:00
|
|
|
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
|
|
|
|
```
|
|
|
|
|
2020-06-23 20:21:47 +02:00
|
|
|
```shell
|
2019-12-31 05:05:02 +01:00
|
|
|
> `open test.csv | uniq`
|
|
|
|
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━
|
|
|
|
# │ first_name │ last_name │ rusty_at │ type
|
|
|
|
───┼────────────┼───────────┼────────────┼──────
|
2020-02-18 15:37:46 +01:00
|
|
|
0 │ Andrés │ Robalino │ 10/11/2013 │ A
|
|
|
|
1 │ Jonathan │ Turner │ 10/12/2013 │ B
|
|
|
|
2 │ Yehuda │ Katz │ 10/11/2013 │ A
|
2019-12-31 05:05:02 +01:00
|
|
|
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━
|
|
|
|
```
|
|
|
|
|
2020-06-23 20:21:47 +02:00
|
|
|
```shell
|
2019-12-31 05:05:02 +01:00
|
|
|
> `open test.csv | get type | uniq`
|
|
|
|
━━━┯━━━━━━━━━
|
2020-06-23 20:21:47 +02:00
|
|
|
# │
|
2019-12-31 05:05:02 +01:00
|
|
|
───┼─────────
|
2020-02-18 15:37:46 +01:00
|
|
|
0 │ A
|
|
|
|
1 │ B
|
2019-12-31 05:05:02 +01:00
|
|
|
━━━┷━━━━━━━━━
|
|
|
|
```
|
2020-06-21 02:22:06 +02:00
|
|
|
|
|
|
|
### Counting
|
2020-06-23 20:21:47 +02:00
|
|
|
|
2020-06-21 02:22:06 +02:00
|
|
|
`--count` or `-c` is the flag to output a `count` column.
|
|
|
|
|
2020-06-23 20:21:47 +02:00
|
|
|
```shell
|
2020-06-21 02:22:06 +02:00
|
|
|
> `open test.csv | get type | uniq -c`
|
|
|
|
───┬───────┬───────
|
2020-06-23 20:21:47 +02:00
|
|
|
# │ value │ count
|
2020-06-21 02:22:06 +02:00
|
|
|
───┼───────┼───────
|
2020-06-23 20:21:47 +02:00
|
|
|
0 │ A │ 3
|
|
|
|
1 │ B │ 2
|
2020-06-21 02:22:06 +02:00
|
|
|
───┴───────┴───────
|
2020-06-23 20:21:47 +02:00
|
|
|
```
|