commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: [CSV] Headers and the first record
Date Tue, 30 Jul 2013 20:15:51 GMT
Hi All:

I see now, the behavior is different depending on what you pass to
withHeader()! Confusing indeed.

If you call withHeader with Strings, the first line is not read and it is
returned as a record.

If you call withHeader with no arguments, the first line _is_ read and it
is NOT returned as a record.

I think I'll change it so that withHeader causes the first line to be
skipped, always, and add an option skipHeaders with a default of true. So
if you really want to set the headers AND see what they are, you can do
that.

Gary


On Tue, Jul 30, 2013 at 3:44 PM, Gary Gregory <garydgregory@gmail.com>wrote:

> Hi All:
>
> I have Excel files with headers. So I use withHeaders() of course to map
> the headers.
>
> When I call parser.iterator().next(), the first record is the header
> record, not data.
>
> I always have to skip this first line since it is not data.
>
> I wonder if:
>
> 1) We should automatically skip the header line for next() and
> parser.getRecords(), or
> 2) Add a skipHeader boolean setting to control the above behavior, where
> the default is...?
>
> (2) is the most flexible.
>
> Thoughts?
>
> Gary
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

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