You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ramiro <ra...@gmail.com> on 2013/01/03 04:14:06 UTC

unmarshall csv problem with bindy

Im working with Karaf 2.2.10 and Camel 2.10.1. I receive a file, parse the
csv to a pojo, and do some other suff. My problem is that if a field in a
record on the csv ends with a coma like the third field here:

someFieldValue,someOtherFieldValue,"aaaa ,",moreStuff

It puts together aaaa , with moreStuff in a single field(ignoring the
second quote). But if i add something like:

someFieldValue,someOtherFieldValue,"aaaa , bbb",moreStuff

It gets processed without a problem(aaaa , bbb in a field, moreStuff in
another). Seems like Camel is interpreting the ," pair like something to
escape.

Im using comma as the separator, and i've tried with other separators and
setting the quote attribute of the @CsvRecord to single and double quotes.


Is this expected behaviour, or some known bug? Any workarounds?

Re: unmarshall csv problem with bindy

Posted by Chris Wolf <cw...@gmail.com>.
On Wed, Jan 16, 2013 at 3:44 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Tue, Jan 15, 2013 at 9:33 PM, Chris Wolf <cw...@gmail.com> wrote:
>> I tried doing some CSV parsing with bindy and had some issues due to
>> variable length records in the same file and other format weirdness.
>> I ended up using camel-beanio.  It's very flexible/configurable and
>> works well.
>>
>
> Yeah I am impressed with beanio as well.
>
> Though I understand why people may like the annotation drive nature of bindy.
> Would love if beanio added that in the future.
>

I would like to see:

1.) Header record "lookahead" to resolve which of multiple possible
groups to match,
     when they have the same initial header type.
    (analogous to left common prefix problem of grammar parsing)  We
need to support
    multiple "entities" represented in CSV format, in the *same* file.
 (kind of a nightmare)
2.) Some kind of callback API to implement record matching "events"

...but yes, annotation driven configuration would be nice as well.
>
>
>>     -Chris
>>
>>
>> http://camel.apache.org/beanio.html
>> http://beanio.org
>>
>> On Wed, Jan 2, 2013 at 10:14 PM, Ramiro <ra...@gmail.com> wrote:
>>> Im working with Karaf 2.2.10 and Camel 2.10.1. I receive a file, parse the
>>> csv to a pojo, and do some other suff. My problem is that if a field in a
>>> record on the csv ends with a coma like the third field here:
>>>
>>> someFieldValue,someOtherFieldValue,"aaaa ,",moreStuff
>>>
>>> It puts together aaaa , with moreStuff in a single field(ignoring the
>>> second quote). But if i add something like:
>>>
>>> someFieldValue,someOtherFieldValue,"aaaa , bbb",moreStuff
>>>
>>> It gets processed without a problem(aaaa , bbb in a field, moreStuff in
>>> another). Seems like Camel is interpreting the ," pair like something to
>>> escape.
>>>
>>> Im using comma as the separator, and i've tried with other separators and
>>> setting the quote attribute of the @CsvRecord to single and double quotes.
>>>
>>>
>>> Is this expected behaviour, or some known bug? Any workarounds?
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen

Re: unmarshall csv problem with bindy

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jan 15, 2013 at 9:33 PM, Chris Wolf <cw...@gmail.com> wrote:
> I tried doing some CSV parsing with bindy and had some issues due to
> variable length records in the same file and other format weirdness.
> I ended up using camel-beanio.  It's very flexible/configurable and
> works well.
>

Yeah I am impressed with beanio as well.

Though I understand why people may like the annotation drive nature of bindy.
Would love if beanio added that in the future.



>     -Chris
>
>
> http://camel.apache.org/beanio.html
> http://beanio.org
>
> On Wed, Jan 2, 2013 at 10:14 PM, Ramiro <ra...@gmail.com> wrote:
>> Im working with Karaf 2.2.10 and Camel 2.10.1. I receive a file, parse the
>> csv to a pojo, and do some other suff. My problem is that if a field in a
>> record on the csv ends with a coma like the third field here:
>>
>> someFieldValue,someOtherFieldValue,"aaaa ,",moreStuff
>>
>> It puts together aaaa , with moreStuff in a single field(ignoring the
>> second quote). But if i add something like:
>>
>> someFieldValue,someOtherFieldValue,"aaaa , bbb",moreStuff
>>
>> It gets processed without a problem(aaaa , bbb in a field, moreStuff in
>> another). Seems like Camel is interpreting the ," pair like something to
>> escape.
>>
>> Im using comma as the separator, and i've tried with other separators and
>> setting the quote attribute of the @CsvRecord to single and double quotes.
>>
>>
>> Is this expected behaviour, or some known bug? Any workarounds?



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: unmarshall csv problem with bindy

Posted by Chris Wolf <cw...@gmail.com>.
I tried doing some CSV parsing with bindy and had some issues due to
variable length records in the same file and other format weirdness.
I ended up using camel-beanio.  It's very flexible/configurable and
works well.

    -Chris


http://camel.apache.org/beanio.html
http://beanio.org

On Wed, Jan 2, 2013 at 10:14 PM, Ramiro <ra...@gmail.com> wrote:
> Im working with Karaf 2.2.10 and Camel 2.10.1. I receive a file, parse the
> csv to a pojo, and do some other suff. My problem is that if a field in a
> record on the csv ends with a coma like the third field here:
>
> someFieldValue,someOtherFieldValue,"aaaa ,",moreStuff
>
> It puts together aaaa , with moreStuff in a single field(ignoring the
> second quote). But if i add something like:
>
> someFieldValue,someOtherFieldValue,"aaaa , bbb",moreStuff
>
> It gets processed without a problem(aaaa , bbb in a field, moreStuff in
> another). Seems like Camel is interpreting the ," pair like something to
> escape.
>
> Im using comma as the separator, and i've tried with other separators and
> setting the quote attribute of the @CsvRecord to single and double quotes.
>
>
> Is this expected behaviour, or some known bug? Any workarounds?

Re: unmarshall csv problem with bindy

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah I think bindy has some issues with parsing data that has optional quotes.

We recently fixed an issue and improved the quote parsing. But there
was an incompatible change so it was only applied on trunk, eg Camel
2.11.

I suggest if you got a bit of time, to try your code against Camel
trunk and see if that fixed your use-case as well.
If not, then feel free to log a JIRA ticket. So we can get it fixed in 2.11.


On Thu, Jan 3, 2013 at 4:14 AM, Ramiro <ra...@gmail.com> wrote:
> Im working with Karaf 2.2.10 and Camel 2.10.1. I receive a file, parse the
> csv to a pojo, and do some other suff. My problem is that if a field in a
> record on the csv ends with a coma like the third field here:
>
> someFieldValue,someOtherFieldValue,"aaaa ,",moreStuff
>
> It puts together aaaa , with moreStuff in a single field(ignoring the
> second quote). But if i add something like:
>
> someFieldValue,someOtherFieldValue,"aaaa , bbb",moreStuff
>
> It gets processed without a problem(aaaa , bbb in a field, moreStuff in
> another). Seems like Camel is interpreting the ," pair like something to
> escape.
>
> Im using comma as the separator, and i've tried with other separators and
> setting the quote attribute of the @CsvRecord to single and double quotes.
>
>
> Is this expected behaviour, or some known bug? Any workarounds?



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen