Home Commons Documentation Team

Commons CSV reads and writes files in variations of the Comma Separated Value (CSV) format.

To parse an Excel CSV file, write:

Reader in = new FileReader("path/to/file.csv"); Iterable<CSVRecord> records = CSVFormat.EXCEL.parse(in); for (CSVRecord record : records) { String lastName = record.get("Last Name"); String firstName = record.get("First Name"); }

Other formats are available, please consult the Javadoc for CSVFormat and CSVParser.

There are currently no official downloads, and will not be until version 1.0 is released, but nightly builds may be available from http://people.apache.org/builds/commons/nightly/commons-csv/.

The latest code can be checked out from our Subversion repository at http://svn.apache.org/repos/asf/commons/proper/csv/trunk/.

You can build the component using Apache Maven 3. For example: mvn clean package. Maven 2 will not work.

Please report any bugs or issues in the Commons Sandbox Jira project at http://issues.apache.org/jira/browse/CSV. Please ask any questions or suggest any ideas for improvement on the commons-dev and commons-user mailing lists.

Commons CSV was started to unify a common and simple interface for reading and writing CSV files under an ASL license. It has been bootstrapped by a code donation from Netcetera in Switzerland. There are three pre-existing BSD compatible CSV parsers which this component will hopefully make redundant (authors willing):

In addition to the code from Netcetera (org.apache.commons.csv), Martin van den Bemt has added an additional writer API.

Other CSV implementations: