You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2023/03/16 06:57:00 UTC

[jira] [Resolved] (CAMEL-19143) Bindy - Add option to quote fields only when necessary

     [ https://issues.apache.org/jira/browse/CAMEL-19143?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-19143.
---------------------------------
    Fix Version/s: 3.21.0
                   4.0-M3
                   4.0
       Resolution: Fixed

> Bindy - Add option to quote fields only when necessary
> ------------------------------------------------------
>
>                 Key: CAMEL-19143
>                 URL: https://issues.apache.org/jira/browse/CAMEL-19143
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-bindy
>    Affects Versions: 3.20.1
>            Reporter: Brice Frisco
>            Priority: Minor
>             Fix For: 3.21.0, 4.0-M3, 4.0
>
>         Attachments: image-2023-03-13-15-14-28-952.png
>
>
> Given a POJO such as:
> {code:java}
> @CsvRecord(generateHeaderColumns = true, separator = ",")
> public class SomeOutput {
>     @DataField(columnName = "hello", pos = 1)
>     private String hello = "Hello,";
>     @DataField(columnName = "world", pos = 2)
>     private String world = "World!";
>     // getters and setters
> }{code}
> And a route such as:
> {code:java}
> from("timer://test?repeatCount=1")
>     .setBody(constant(new SampleOutput()))
>     .marshal(CSV_FORMAT)
>     .log("${body}"); {code}
> Bindy produces this output:
> {code:java}
> hello,world
> Hello,,World! {code}
> Which looks like the following in CSV format:
> !image-2023-03-13-15-14-28-952.png!
>  
> Fields which contain the chosen separator are not automatically escaped or quoted. One workaround to this is to add `quoting=true` to the `CsvRecord`, which will quote all fields.
> I think it would be nice if an option existed that would quote fields only when it is necessary, which can reduce the file size. This method of dynamic quoting is the way it is handled by default in Excel on Windows systems.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)