Yet another CSV reader/pull parser/stream parser with small memory usage.
All credit goes to:
- Rob Pike, creator of Scanner interface,
- D. Richard Hipp, for his CSV parser implementation.
Iterating over fields
CsvScanner s;
while (s.scan())) {
String value = s.value();
// ...
if (s.atEndOfRow()) {
// ...
}
}
Iterating over records
CsvReader r;
while (r.next()) {
String value1 = r.getString(1);
// ...
}
Round Tripping
CsvWriter w;
CsvScanner s;
while (s.scan())) {
w.write(s.value());
if (s.atEndOfRow()) {
w.endOfRow();
}
}
w.flush();
or
CsvWriter w;
CsvReader r;
while (r.next()) {
w.writeRow(r.values());
}
w.flush();
LICENSE
Public Domain