Crates.io | pretty-csv |
lib.rs | pretty-csv |
version | 0.2.0 |
source | src |
created_at | 2023-02-12 16:19:23.421271 |
updated_at | 2023-02-12 16:55:42.672578 |
description | CSV terminal pretty-printer |
homepage | |
repository | https://gitlab.com/wake-sleeper/pretty-csv |
max_upload_size | |
id | 783293 |
size | 23,046 |
Pretty-print your csv files to the terminal:
use pretty_csv::Table;
let mut csv = &b"one,two\nthree,four"[..];
let table = Table::from_csv(csv);
let mut output = vec![];
table.draw(&mut output).unwrap();
assert_eq!(
std::str::from_utf8(&output).unwrap(),
concat!(
"╭───────┬──────╮\n",
"│ one │ two │\n",
"├───────┼──────┤\n",
"│ three │ four │\n",
"╰───────┴──────╯\n"
)
);
Supports embedding tables in cells:
use pretty_csv::Table;
let mut csv = &b"one,two\n\"[three,four\nfive,six]\",seven"[..];
let table = Table::from_csv(csv);
let mut output = vec![];
table.draw(&mut output).unwrap();
assert_eq!(
std::str::from_utf8(&output).unwrap(),
concat!(
"╭──────────────────┬───────╮\n",
"│ one │ two │\n",
"├──────────────────┼───────┤\n",
"│ ╭───────┬──────╮ │ seven │\n",
"│ │ three │ four │ │ │\n",
"│ ├───────┼──────┤ │ │\n",
"│ │ five │ six │ │ │\n",
"│ ╰───────┴──────╯ │ │\n",
"╰──────────────────┴───────╯\n"
)
);
Comes with small cli tool called pretty-csv
:
$ cargo install pretty-csv
$ echo "1,2,3" | pretty-csv
╭───┬───┬───╮
│ 1 │ 2 │ 3 │
╰───┴───┴───╯