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 Wed, 31 Jul 2013 13:08:30 GMT
On Tue, Jul 30, 2013 at 5:47 PM, Emmanuel Bourg <ebourg@apache.org> wrote:

> Le 30/07/2013 23:24, Gary Gregory a écrit :
>
> > Yeah, that's too clever IMO. I expected the same behavior WRT record
> > reading with the only difference being if I let the parser guess or not.
>
> Too clever? I didn't feel like I designed a rocket with this feature
> though :) That's an important feature to me and I'd like to preserve it.
>
> If the header is defined in the file I don't want to skip the first
> record manually, the parser should take care of it.


But that is exactly what _was_ happening! ;)

If I called withHeader("A", "B", "C") the header was not skipped.
If I called withHeader(new String[]{}) the header was skipped.
If I called withHeader() the header was skipped (same as line above).

In both cases, I am telling the parser that there is a header, but it is
not skipped in both cases. That's the inconsistency I fixed.

What I am asking is: should we have a saveHeader setting such that IF you
ask for headers, then we save that record in the parser, it is currently
"lost", or, actually transformed into the header map.

Gary


> That also means the
> user code can remain the same, whether the header is defined in the code
> or in the file.
>
>
> > The current code now always reads the header line if you set any non-null
> > header. If you call withHeader() with no args it is a non-null call with
> an
> > empty String[].
>
> I guess a null header or an empty header is just the same and means the
> first record must be used as the header.
>
> Emmanuel Bourg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
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