You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Benedikt Ritter <br...@apache.org> on 2016/05/01 21:05:27 UTC

[CSV] Some tweaks for working with headers

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

Re: [CSV] Some tweaks for working with headers

Posted by Gary Gregory <ga...@gmail.com>.
On Tue, May 3, 2016 at 11:36 AM, Benedikt Ritter <br...@apache.org> wrote:

> Gary Gregory <ga...@gmail.com> schrieb am Di., 3. Mai 2016 um
> 20:16 Uhr:
>
> > @Benedikt: Would you be able to RM these and what is trunk out in to
> > release?
> >
>
> I was already thinking about this, we have a lot of nice new things in
> trunk. I'll be on vacation next week. If I can't manage to push an RC out
> this week, I'll do it after my vacation.
>

Sounds good.

Gary


>
> Benedikt
>
>
> >
> > Gary
> >
> > On Tue, May 3, 2016 at 9:33 AM, Benedikt Ritter <br...@apache.org>
> > wrote:
> >
> > > I have created CSV-179 [1] and CSV-180 [2] for this.
> > >
> > > [1] https://issues.apache.org/jira/browse/CSV-179
> > > [2] https://issues.apache.org/jira/browse/CSV-180
> > >
> > >
> > > Gary Gregory <ga...@gmail.com> schrieb am So., 1. Mai 2016 um
> > > 22:26 Uhr:
> > >
> > > > This all sounds good to me.
> > > >
> > > > Gary
> > > > On May 1, 2016 12:05 PM, "Benedikt Ritter" <br...@apache.org>
> wrote:
> > > >
> > > > > 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
> > > > >
> > > >
> > >
> >
> >
> >
> > --
> > 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

Re: [CSV] Some tweaks for working with headers

Posted by Benedikt Ritter <br...@apache.org>.
Gary Gregory <ga...@gmail.com> schrieb am Di., 3. Mai 2016 um
20:16 Uhr:

> @Benedikt: Would you be able to RM these and what is trunk out in to
> release?
>

I was already thinking about this, we have a lot of nice new things in
trunk. I'll be on vacation next week. If I can't manage to push an RC out
this week, I'll do it after my vacation.

Benedikt


>
> Gary
>
> On Tue, May 3, 2016 at 9:33 AM, Benedikt Ritter <br...@apache.org>
> wrote:
>
> > I have created CSV-179 [1] and CSV-180 [2] for this.
> >
> > [1] https://issues.apache.org/jira/browse/CSV-179
> > [2] https://issues.apache.org/jira/browse/CSV-180
> >
> >
> > Gary Gregory <ga...@gmail.com> schrieb am So., 1. Mai 2016 um
> > 22:26 Uhr:
> >
> > > This all sounds good to me.
> > >
> > > Gary
> > > On May 1, 2016 12:05 PM, "Benedikt Ritter" <br...@apache.org> wrote:
> > >
> > > > 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
> > > >
> > >
> >
>
>
>
> --
> 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
>

Re: [CSV] Some tweaks for working with headers

Posted by Gary Gregory <ga...@gmail.com>.
@Benedikt: Would you be able to RM these and what is trunk out in to
release?

Gary

On Tue, May 3, 2016 at 9:33 AM, Benedikt Ritter <br...@apache.org> wrote:

> I have created CSV-179 [1] and CSV-180 [2] for this.
>
> [1] https://issues.apache.org/jira/browse/CSV-179
> [2] https://issues.apache.org/jira/browse/CSV-180
>
>
> Gary Gregory <ga...@gmail.com> schrieb am So., 1. Mai 2016 um
> 22:26 Uhr:
>
> > This all sounds good to me.
> >
> > Gary
> > On May 1, 2016 12:05 PM, "Benedikt Ritter" <br...@apache.org> wrote:
> >
> > > 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
> > >
> >
>



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

Re: [CSV] Some tweaks for working with headers

Posted by Benedikt Ritter <br...@apache.org>.
I have created CSV-179 [1] and CSV-180 [2] for this.

[1] https://issues.apache.org/jira/browse/CSV-179
[2] https://issues.apache.org/jira/browse/CSV-180


Gary Gregory <ga...@gmail.com> schrieb am So., 1. Mai 2016 um
22:26 Uhr:

> This all sounds good to me.
>
> Gary
> On May 1, 2016 12:05 PM, "Benedikt Ritter" <br...@apache.org> wrote:
>
> > 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
> >
>

Re: [CSV] Some tweaks for working with headers

Posted by Gary Gregory <ga...@gmail.com>.
This all sounds good to me.

Gary
On May 1, 2016 12:05 PM, "Benedikt Ritter" <br...@apache.org> wrote:

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