Apache Commons logo Commons CSV™ logo

Using Commons CSV

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.

Getting the code

There are currently no official downloads, and will not be until version 1.0 is released.

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. For example: mvn clean package.

Reporting bugs

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.

About Commons CSV

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: