commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject [CSV] Some tweaks for working with headers
Date Sun, 01 May 2016 19:05:27 GMT
Hi,

I often seeing myself doing the following when my csv file has a header row:

CSVFormat.RFC4180
   .withHeader() // use first row as header
   .withSkipHeaderRecord();

How about combining the two into a method called withFirstRecordAsHeader()
or something like that?

Further more I find it unsymmetrical that I can retrieve a column value
from CSVRecord using an enum, but I cannot pass an enum to CSVFormat to
define a header. So I'd like to add a new overload of withHeader:

withHeader(Class<? extends Enum> headers)

The method would iterate over the enum values defined by the class and use
the name() method on each value for defining the header. This way I can
define an enum for my headers, use it when specifying the format and when
retrieving values from the records.

Thoughts?
Benedikt

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message