1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
/*
Following main function will print :
+---------+------+---------+
| ABC | DEFG | HIJKLMN |
+---------+------+---------+
| foobar | bar | foo |
+---------+------+---------+
| foobar2 | bar2 | foo2 |
+---------+------+---------+
ABC,DEFG,HIJKLMN
foobar,bar,foo
foobar2,bar2,foo2
*/
#[cfg(feature = "csv")]
fn main() {
use prettytable::Table;
let table = Table::from_csv_string(
"ABC,DEFG,HIJKLMN\n\
foobar,bar,foo\n\
foobar2,bar2,foo2",
)
.unwrap();
table.printstd();
println!("");
println!(
"{}",
String::from_utf8(table.to_csv(Vec::new()).unwrap().into_inner().unwrap()).unwrap()
);
}
#[cfg(not(feature = "csv"))]
fn main() {}