Thursday, July 19, 2007

CSV reading from Java

If you need to process CSV files, for example as a result of an export from Excel or Calc, then try CsvReader, an LGPL Java-library. It works remarkably simple:
CsvReader reader = new CsvReader("input.csv");

// Read all headers (the first line)

// Read all remaining lines
while (reader.readRecord()) {
String productID = reader.get("ProductID");
// etc.

I'm using CsvReader 2.0, released in December 2006.

No comments:

Post a Comment