summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorPierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com>2016-09-13 21:11:07 +0200
committerPierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com>2016-09-13 21:11:07 +0200
commit5a4251deb80bdd3d16460f0224ee9928b4f42736 (patch)
tree8c8e0efb4333db30395f4ab2a8b08dbfaffc53df /examples
parente11621c19ce2c68c0052be04080be75a6ba66396 (diff)
parent0b26d80739ed733e6f59877e744248fd19334bd8 (diff)
Merge remote-tracking branch 'refs/remotes/nabijaczleweli/master'
Conflicts: Cargo.toml src/lib.rs
Diffstat (limited to 'examples')
-rw-r--r--examples/csv.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/examples/csv.rs b/examples/csv.rs
new file mode 100644
index 0000000..df14173
--- /dev/null
+++ b/examples/csv.rs
@@ -0,0 +1,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());
+}