Category Archives: csv

Converting ODS to CSV

>Recently I’ve released an ODS (OpenDocument Spreadsheet) to CSV (Comma-Separated Values) converter. It’s available from GitHub:

The current version (0.1) is not perfect, I’ve documented some issues, mainly related to empty fields/records being output. After releasing version 0.1 I created some unit tests; once they pass, these issues should be resolved.

During development, it turned out it’s really easy to parse an ODS file, since it’s just a ZIP file with the contents contained in simple XML file inside it.

The converter uses SAX to parse the XML inside it, to minimize memory usage. It comes with a Java library, a command line program and an Apache Ant task. And there are no external dependencies other than a Java runtime environment (version 1.5 or up).


>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.

Leave a comment

Posted by on 19 July 2007 in calc, csv, csvreader, excel, export, import, java, oo,