The table is a simple tool to transform table data in CSV or SQL/CQL output format.
If you have a SQL output like that
---- ------------ ----------- -----------
| id | first_name | last_name | available |
---- ------------ ----------- -----------
| 1 | John | Smith | 1 |
| 2 | Mary | McAdams | 0 |
| 3 | Steve | Pitt | 1 |
...
you can easilly get a list of available only users:
$ table in.sql --filter available=1
╭────┬────────────┬───────────┬───────────╮
│ id │ first_name │ last_name │ available │
├────┼────────────┼───────────┼───────────┤
│ 1 │ John │ Smith │ 1 │
│ 3 │ Steve │ Pitt │ 1 │
│ 4 │ Mark │ Cousins │ 1 │
...
Also in CSV form:
$ table in.sql --filter available=1 --as csv
Or in a custom text format:
$ table in.sql --print '${first_name} ${last_name}' --filter available=1
John Smith
Steve Pitt
...
- Parsing table data from CSV (with simple automatic delimeter detection), SQL or Cassandra outputs
- Filtering columns based on certain criteria. Filter attempts to correctly interpret numbers (but not floating point numbers yet), instead of using only string to string comparison.
- Overriding table header to a custom one
- Moving/removing columns
- Dynamically adding new columns from a shell script output based on row data
- Custom formatting for table rows
- Automatically naming columns: col1, col2, col3 etc. if header is not specified.
- Joining of multiple table inputs
- Showing only distinct data for a column
- Sorting by the specified columns
- Reduce functions
Using homebrew on OSX or Linux:
$ brew tap sergkh/tap
$ brew install table-cli
Currently tool is built for OSX (both Intel and Apple silicon) and Linux.
- Transform SQL output from the clipboard into CSV:
OSX:
pbcopy | table
Linux:
xsel -b | table
- Filter CSV rows and show first 5 matches:
table in.csv --filter 'in_stock>=10' --limit 5
- Show only specified CSV columns:
table in.csv --columns 'name,last_name'
- Append a new column that has result of multiplication of two other columns. To substitute column value in the command
${column name}
format should be used. New column gets name 'newColumn1':
table in.csv --add 'echo "${cost} * ${amount}" | bc'
- Joining two CSV files by a common column. Joins on the column named 'id' in the first file that should match 'product_id' in the second file:
table file1.csv --join file2.csv --on 'id=product_id'
- Sort columns first descending by the 'available' column and then ascending by the 'id' column:
table ./test-data/table-format.out --sort "!available,id"
swift build -c release