Crates.io | very_primitive_tables |
lib.rs | very_primitive_tables |
version | 0.1.3 |
source | src |
created_at | 2023-09-29 23:17:41.394489 |
updated_at | 2023-09-29 23:44:40.537088 |
description | Primitive pretty-printing functionality for tables. This is mainly meant as a way for me to learn how to publish code. There are surely other options. |
homepage | |
repository | https://github.com/davidpalensky/very_primitive_tables/ |
max_upload_size | |
id | 988151 |
size | 8,752 |
This library is basically for pretty-printing two dimensional vectors of strings. I created it because I had nothing to do, so issues probably won't be fixed.
It also has some basic csv loading ability. It does nothing else. It has no dependencies. It is slightly annoying to use.
main.rs:
use very_primitive_tables::vec2d::csv_to_vec2d_ref;
use very_primitive_tables::Table;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let table = csv_to_vec2d_ref(include_str!("../test.csv"));
let table = Table::from_vec2d(&table)?;
print!("table =\n{}", table.render());
Ok(())
}
test.csv:
x,y,x_error
0.06,0.60,0.0024
0.11,1.20,0.0033
0.17,1.80,0.0083
0.23,2.40,0.0048
0.31,3.00,0.0056
0.38,3.60,0.0124
produces:
+------+------+---------+
| x | y | x_error |
+------+------+---------+
| 0.06 | 0.60 | 0.0024 |
+------+------+---------+
| 0.11 | 1.20 | 0.0033 |
+------+------+---------+
| 0.17 | 1.80 | 0.0083 |
+------+------+---------+
| 0.23 | 2.40 | 0.0048 |
+------+------+---------+
| 0.31 | 3.00 | 0.0056 |
+------+------+---------+
| 0.38 | 3.60 | 0.0124 |
+------+------+---------+