summaryrefslogtreecommitdiffstats
path: root/examples/csv.rs
blob: f9202e7f80c4470bff9d4d528abba08a29fefdda (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
27
28
29
30
31
extern crate prettytable;

/*
	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!("{}", table.to_csv(Vec::new()).unwrap().into_string());
}

#[cfg(not(feature = "csv"))]
fn main() {}