csviewer is command line csv viewer.
go get github.com/Konboi/csviewer
using p
or path
option
csviewer -p _example/example.csv
cat _example/example.csv | csviewer
$ csviewer -p _example/example.csv
+----+------+----------------+-----------+--------+
| ID | NAME | MAIL | PHONE | ADRESS |
+----+------+----------------+-----------+--------+
| 1 | a | [email protected] | 123456 | 111111 |
| 2 | b | [email protected] | 12345 | |
| 3 | c | | | 22222 |
| 5 | d | [email protected] | 123456789 | |
+----+------+----------------+-----------+--------+
set display columns.
$ csviewer -p _example/example.csv -c id,mail,name
+----+----------------+------+
| ID | MAIL | NAME |
+----+----------------+------+
| 1 | [email protected] | a |
| 2 | [email protected] | b |
| 3 | | c |
| 5 | [email protected] | d |
+----+----------------+------+
set display rows num.
$ csviewer -p _example/example.csv -l 2
+----+------+----------------+--------+--------+
| ID | NAME | MAIL | PHONE | ADRESS |
+----+------+----------------+--------+--------+
| 1 | a | [email protected] | 123456 | 111111 |
| 2 | b | [email protected] | 12345 | |
+----+------+----------------+--------+--------+
set display condition.
$ ./csviewer -p _example/example.csv -f "id > 2"
+----+------+---------------+-----------+--------+
| ID | NAME | MAIL | PHONE | ADRESS |
+----+------+---------------+-----------+--------+
| 3 | c | | | 22222 |
| 5 | d | [email protected] | 123456789 | |
+----+------+---------------+-----------+--------+
$ csviewer -p _example/example.csv -f 'phone > 12345'
+----+------+----------------+-----------+--------+
| ID | NAME | MAIL | PHONE | ADRESS |
+----+------+----------------+-----------+--------+
| 1 | a | [email protected] | 123456 | 111111 |
| 5 | d | [email protected] | 123456789 | |
$ ./csviewer -p _example/example.csv -f "id > 2 && id <= 10"
+----+------+-----------------+-----------+--------+
| ID | NAME | MAIL | PHONE | ADRESS |
+----+------+-----------------+-----------+--------+
| 3 | c | | | 22222 |
| 5 | d | [email protected] | 123456789 | |
| 10 | e | [email protected] | 654321 | |
+----+------+-----------------+-----------+--------+
$ ./csviewer -p _example/example.csv -f "id > 2" -f "id <= 10"
+----+------+-----------------+-----------+--------+
| ID | NAME | MAIL | PHONE | ADRESS |
+----+------+-----------------+-----------+--------+
| 3 | c | | | 22222 |
| 5 | d | [email protected] | 123456789 | |
| 10 | e | [email protected] | 654321 | |
+----+------+-----------------+-----------+--------+
$ ./csviewer -p _example/example.csv -f "name == 'c'" -f "name == 'd'" -or
+----+------+---------------+-----------+--------+
| ID | NAME | MAIL | PHONE | ADRESS |
+----+------+---------------+-----------+--------+
| 3 | c | | | 22222 |
| 5 | d | [email protected] | 123456789 | |
+----+------+---------------+-----------+--------+
$ ./csviewer -p _example/example.csv -f "name == 'c' || name == 'd'"
+----+------+---------------+-----------+--------+
| ID | NAME | MAIL | PHONE | ADRESS |
+----+------+---------------+-----------+--------+
| 3 | c | | | 22222 |
| 5 | d | [email protected] | 123456789 | |
+----+------+---------------+-----------+--------+
$ csviewer -p _example/example.csv -s 'phone asc'
+-----+-------+-----------------+-----------+--------+
| ID | NAME | MAIL | PHONE | ADRESS |
+-----+-------+-----------------+-----------+--------+
| 3 | c | | | 22222 |
| 2 | b | [email protected] | 12345 | |
| 1 | a | [email protected] | 123456 | 111111 |
| 10 | e | [email protected] | 654321 | |
| 5 | d | [email protected] | 123456789 | |
| 222 | asdfg | [email protected] | 987654321 | |
+-----+-------+-----------------+-----------+--------+
$ csviewer -p _example/example.csv -s 'mail desc'
+-----+-------+-----------------+-----------+--------+
| ID | NAME | MAIL | PHONE | ADRESS |
+-----+-------+-----------------+-----------+--------+
| 10 | e | [email protected] | 654321 | |
| 5 | d | [email protected] | 123456789 | |
| 2 | b | [email protected] | 12345 | |
| 222 | asdfg | [email protected] | 987654321 | |
| 1 | a | [email protected] | 123456 | 111111 |
| 3 | c | | | 22222 |
+-----+-------+-----------------+-----------+--------+
$ csviewer --help
Usage of csviewer:
-c string
print specify columns
-columns string
print specify columns
-f value
filter
-filter value
filter
-l int
set max display rows num
-limit int
set max display rows num
-p string
set csv file path
-path string
set csv file path
-s string
sort by set value
ex) id desc/ hoge_id asc
-sort string
sort by set value
ex) id desc/ hoge_id asc
- Order option
- Set multi filters in one column