pretty-csv

Crates.iopretty-csv
lib.rspretty-csv
version0.2.0
sourcesrc
created_at2023-02-12 16:19:23.421271
updated_at2023-02-12 16:55:42.672578
descriptionCSV terminal pretty-printer
homepage
repositoryhttps://gitlab.com/wake-sleeper/pretty-csv
max_upload_size
id783293
size23,046
Eze Anyanwu (eze-works)

documentation

README

Pretty CSV

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 │
╰───┴───┴───╯
Commit count: 5

cargo fmt