Tidy Viewer (tv) is a csv pretty printer that uses column styling to maximize viewer enjoyment.
The following will install from the crates.io source. For convenience add the alas alias tv='tidy-viewer'
to bashrc.
sh
cargo install tidy-viewer
sudo cp /home/ubuntu/.cargo/bin/tidy-viewer /usr/local/bin/.
echo "alias tv='tidy-viewer'" >> ~/.bashrc
source ~/.bashrc
The current version is alpha. I do not plan to push to crates.io until this is more polished. If you would like to try this in its raw state install rust and follow the steps below.
cargo build --release
bin
alias tv='tidy-viewer'
to ~/.bashrc
sh
git clone https://github.com/alexhallam/tv
cd tv
cargo build --release
sudo cp ./target/release/tv /usr/local/bin/.
echo "alias tv='tidy-viewer'" >> ~/.bashrc
source ~/.bashrc
```sh
wget https://raw.githubusercontent.com/tidyverse/ggplot2/master/data-raw/diamonds.csv
cat diamonds.csv | head -n 35 | tv ```
The first three digits. The first three digits represent > 99.9% the value of a number. -- GNU-R Pillar
tv
uses the same significant figure (sigfig) rules that the R package pillar
uses.
The purpose of the sigfig rules in tv
is to guide the eye to the most important information in a number. This section defines terms and the decision tree used in the calculation of the final value displayed.
```text ┌─────┐ ┌─────┐ ─┐ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌┐ │ │ │ └─────┘ └┘ └─────┘ ──┴─ │ │ │ │ └────────┘ ▲ └────────────────┘ left hand side │ right hand side (lhs) │ (rhs)
decimal
```
left hand side (lhs): digits on the left hand side of the decimal.
right hand side (rhs): digits on the right hand side of the decimal.
```text
┌─────┐ ┌─────┐ ─┐ ┌─────┐ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌┐ │ │ │ │ │ └─────┘ └┘ └─────┘ ──┴─ └─────┘
│ │ │ │ └─────────────────────┘ └───────┘ leading 0s trailing 0s ``` leading 0s: 0s to the left of a non-zero.
trailing 0s: 0s to the right of a non-zero. The zeros in 500m are trailing as well as the 0s in 0.500km.
```text ─┐ ┌─────┐ ─┐ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌┐ │ ──┴─ └─────┘ └┘ ──┴─
│ │
└────────┘
fractional digit(s)
```
fractional digits: Digits on the rhs of the decimal. The represent the non-integer part of a number.
There are only 4 outputs possible. The significant figures to display are set by the user. Assume sigfig = 3
:
12345.0 -> 12345
): If no fractional digits are present and lhs >= sigfig then return lhs1234.5 -> 1234.
): If fractional digits are present and lhs >= sigfig then return lhs with point. This is to let the user know that some decimal dust is beyond the main mass of the number.1.2345 -> 1.23
): If fractional digits are present and lhs < sigfig return the first three digits of the number.0.00001 -> 0.0001
): This is reserved for values with leading 0s in the rhs.```text
if lhs == 0: //n = ((floor(log10(abs(x))) + 1 - sigfig) //r =(10^n) * round(x / (10^n)) //return r // (0.12345 -> 0.123) else: if log10(lhs) + 1 > sigfig: if rhs > 0: //concatonate: //(lhs) //(point) //(123.45 -> 123.) //(123.45 -> 123.) else: //concatonate: //(lhs) //(1234.0 -> 1234) //(100.0 -> 100) else: //concatonate: //(lhs) //(point) //sigfig - log10(lhs) from rhs //(12.345 -> 12.3) //(1.2345 -> 1.23) ```
tv
is a good compliment to command line data manipulation tools. I have listed some tools that I like to use with tv.
xsv - Command line csv data manipulation. Rust
csvtk - Command line csv data manipulation. Go
tsv-utils - Command line csv data manipulation toolkit. D
q - Command line csv data manipulation query-like. Python
miller - Commane line data manipulaiton, statistics, and more. C
xsv - a command line program for indexing, slicing, analyzing, splitting and joining CSV files
tsv-utils - command line utilities for tabular data files
q - q is a command line tool that allows direct execution of SQL-like queries on CSVs/TSVs
miller - Miller is like awk, sed, cut, join, and sort for data formats such as CSV, TSV, tabular JSON and positionally-indexed.
column
Comes standard with linux. To get similar functionality run column file.csv -ts,
pillar - R's tibble like formatting