Skip to content

gwenn/scanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Build Status Maven Central Javadocs

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