commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Bourg <>
Subject Re: [csv] Headers
Date Thu, 15 Mar 2012 00:58:53 GMT
There is another alternative, we might replace the records returned as a 
String[] by a CSVRecord class able to access the fields by id or by 
name. This would be similar to a JDBC resultset (except for the looping 

This avoids the duplication of the parser, which might still be 
generified later to support custom beans.

The example becomes:

   CSVFormat format = CSVFormat.DEFAULT.withHeader();

   for (CSVRecord record : format.parse(in)) {
       Person person = new Person();

The record is not a Map to keep it simple, it only exposes 3 methods: 
get(int), get(String) and size()

Emmanuel Bourg

View raw message