Why CsvDataFormat generate character '[' & ']' - CSV annotations

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Why CsvDataFormat generate character '[' & ']' - CSV annotations

Charles Moulliard
Hi,

Why the CSVDataFormat add those characters from and after a CSV line '[' ']' ?

ex of body message displaying those characters.
[[1, bank1, 10, 20, sale], [2, bank2, 10, 5, sale], [3, bank3, 1000, 2000, buy], ...

Remark : the file parsed using CSVDataformat is placed as a message in a queue.

       from("file:///c:/temp/test?noop=true")
        .unmarshal().csv()
        .to("test-jms:queue:test.queue");

May I suggest you to avoid the generation of such characters because those tags must be remove during the process to map CSV line content to a POJO !

Is it possible to have CSV annotations (like it is possible in the ETL example with XML file) in order to map the content of a CSV line to a POJO ?

regards,

Charles
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Why CsvDataFormat generate character '[' & ']' - CSV annotations

gertv
Charles,

I think the CSV file is transformed into a Java List object, which might
be the reason why you see the [ ] in there when printing the message body.

Gert

cmoulliard wrote:

> Hi,
>
> Why the CSVDataFormat add those characters from and after a CSV line '[' ']'
> ?
>
> ex of body message displaying those characters.
> [[1, bank1, 10, 20, sale], [2, bank2, 10, 5, sale], [3, bank3, 1000, 2000,
> buy], ...
>
> Remark : the file parsed using CSVDataformat is placed as a message in a
> queue.
>
>        from("file:///c:/temp/test?noop=true")
>         .unmarshal().csv()
>         .to("test-jms:queue:test.queue");
>
> May I suggest you to avoid the generation of such characters because those
> tags must be remove during the process to map CSV line content to a POJO !
>
> Is it possible to have CSV annotations (like it is possible in the ETL
> example with XML file) in order to map the content of a CSV line to a POJO ?
>
> regards,
>
> Charles
>  

Reply | Threaded
Open this post in threaded view
|

Re: Why CsvDataFormat generate character '[' & ']' - CSV annotations

Charles Moulliard
Gert,

You are right. We receive a Java Object List

                // Extract the messages from the body
                messages = (List<String>) body;

                for (Iterator itermessages = messages.iterator(); itermessages
                                .hasNext();) {
                       
                        // Get each message
                        message = (String[]) itermessages.next();

                        for (Iterator itermessage = messages.iterator(); itermessage
                                        .hasNext();) {
                               
                                // Split the content of the message into field
                                field = (String[]) itermessage.next();



Gert Vanthienen wrote
Charles,

I think the CSV file is transformed into a Java List object, which might
be the reason why you see the [ ] in there when printing the message body.

Gert

cmoulliard wrote:
> Hi,
>
> Why the CSVDataFormat add those characters from and after a CSV line '[' ']'
> ?
>
> ex of body message displaying those characters.
> [[1, bank1, 10, 20, sale], [2, bank2, 10, 5, sale], [3, bank3, 1000, 2000,
> buy], ...
>
> Remark : the file parsed using CSVDataformat is placed as a message in a
> queue.
>
>        from("file:///c:/temp/test?noop=true")
>         .unmarshal().csv()
>         .to("test-jms:queue:test.queue");
>
> May I suggest you to avoid the generation of such characters because those
> tags must be remove during the process to map CSV line content to a POJO !
>
> Is it possible to have CSV annotations (like it is possible in the ETL
> example with XML file) in order to map the content of a CSV line to a POJO ?
>
> regards,
>
> Charles
>  



-----
---
Gert Vanthienen
http://www.anova.be
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com