Public.Standards.CSV
This module was made following http://en.wikipedia.org/wiki/Comma-separated_valuesThe examples shown below use the sample CSV file provided by the fore-mentionned documentation. FilesPublic.Standards.CSV.FILE() inherits from the buffered Stdio.FILE() class.It sports two important methods:
ReadingThe method-way:
object infile = Public.Standards.CSV.FILE("/tmp/sample.csv", "r");
infile->read_row();
(1) Result: ({ /* 5 elements */
"1997",
"Ford",
"E350",
"ac, abs, moon",
"3000.00"
})
object infile = Public.Standards.CSV.FILE("/tmp/sample.csv", "r");
foreach(infile; int line_number; array data) {
//...
}
Writing
object outfile = Public.Standards.CSV.FILE("/tmp/foo.csv", "cw");
outfile->write_row("foo","bar","baz");
(1) Result: 13
Powered by PikeWiki2 |
|||
| gotpike.org | Copyright © 2004 - 2009 | Pike is a trademark of Department of Computer and Information Science, Linköping University | |||