You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Aviraj <av...@outlook.com> on 2013/10/23 13:54:23 UTC

Encapsulate each field by double quotes

Hello,
I am trying to encapsulate the data in CSV file by double quotes with
CSVStrategy Configuration. But the data in the CSV is not encapsulated by
double quotes. The code snippet is as below,
    public void configure() throws Exception {
        CsvDataFormat format = new CsvDataFormat();
        format.setStrategy(new CSVStrategy(',', '"', '#'));

        from(TEST)
            .to("sql:" + TEST_SQL+ "?dataSource=#dataSource")
            .process(new TestProcessor())
            .setHeader(FILE_NAME, "Test.csv")
            .setBody(simple("${body}"))
            .marshal(format)
            .convertBodyTo(String.class)
            .to("file:?tempFileName=${file:onlyname.noext}.tmp")
    }

@Experts: Please let me know whether I am missing something here?

Thanks in advance!



--
View this message in context: http://camel.465427.n5.nabble.com/Encapsulate-each-field-by-double-quotes-tp5742070.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Encapsulate each field by double quotes

Posted by Claus Ibsen <cl...@gmail.com>.
I suggest to look in the commons CSV project about how to use double
quotes. And if that is supported, and that you configure the
CSVStrategy correct?

Also you can try alternatives than CSV such as camel-beanio etc as its
an up to date and maintained project, where as commons csv is a sort
of dead project.



On Wed, Oct 23, 2013 at 1:54 PM, Aviraj <av...@outlook.com> wrote:
> Hello,
> I am trying to encapsulate the data in CSV file by double quotes with
> CSVStrategy Configuration. But the data in the CSV is not encapsulated by
> double quotes. The code snippet is as below,
>     public void configure() throws Exception {
>         CsvDataFormat format = new CsvDataFormat();
>         format.setStrategy(new CSVStrategy(',', '"', '#'));
>
>         from(TEST)
>             .to("sql:" + TEST_SQL+ "?dataSource=#dataSource")
>             .process(new TestProcessor())
>             .setHeader(FILE_NAME, "Test.csv")
>             .setBody(simple("${body}"))
>             .marshal(format)
>             .convertBodyTo(String.class)
>             .to("file:?tempFileName=${file:onlyname.noext}.tmp")
>     }
>
> @Experts: Please let me know whether I am missing something here?
>
> Thanks in advance!
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Encapsulate-each-field-by-double-quotes-tp5742070.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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