commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Bourg <ebo...@apache.org>
Subject Re: [csv] Headers
Date Tue, 13 Mar 2012 00:37:28 GMT
Le 13/03/2012 00:56, sebb a écrit :

>> 1. Do nothing and address it in the next release with the bean mapping.
>> Parsing the file would then look like this:
>>
>>   CSVFormat<Person>  format = CSVFormat.DEFAULT.withType(Person.class);
>>   for (Person person : format.parse(in)) {
>>       persons.add(person);
>>   }
>>
>
> Does this automatically mean that the file has a header?
> Or is there another way to link columns to Person attributes?

If the file doesn't have a header, the fields are matched by index 
(either the natural ordering of the attributes in the class, or 
specified by an annotation).

If the file has a header, the fields are matched by attribute name, and 
an annotation can override the name of the column associated to an 
attribute.


Emmanuel Bourg


Mime
View raw message