summaryrefslogtreecommitdiffstats
path: root/examples/csv.rs
blob: df141737b11e951573230d94c8496204c7840e72 (plain)
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
extern crate prettytable;
use prettytable::Table;

/*
	Following main function will print :
	+---------+------+---------+
	| ABC     | DEFG | HIJKLMN |
	+---------+------+---------+
	| foobar  | bar  | foo     |
	+---------+------+---------+
	| foobar2 | bar2 | foo2    |
	+---------+------+---------+

    ABC,DEFG,HIJKLMN
    foobar,bar,foo
    foobar2,bar2,foo2
*/
fn main() {
    let table = Table::from_csv_string("ABC,DEFG,HIJKLMN\n\
                                        foobar,bar,foo\n\
                                        foobar2,bar2,foo2").unwrap();
    table.printstd();

    println!("");
    println!("{}", table.to_csv(Vec::new()).unwrap().into_string());
}