this is not a bug. as you have comma as separator, in the line you have
exception you have too many fields already. so illegal argument exception
seems correct in the given case.


On Wed, 19 Apr 2017 at 08:10, sadiq <[email protected]> wrote:

> I'm experiencing a parsing issue using Bindy to unmarshal a CSV file into a
> List of POJOs (my POJO class is annotated with @CsvRecord).
>
> The CSV file contains the following:
>
> partNumber,longDescription,status
> 123,"1970-84 Windshield Washer Jar, Multi Application",Available
> 234,"1967-75 6 Cyl/ Small Block 9"" Clutch Bellcrank Assembly",Available
> 345,"1971-79 Fan Blade 19-1/2"", 7 Blade",Available
>
> It's the fourth line that is causing an issue:
> java.lang.IllegalArgumentException: No position 4 defined for the field:
> Available, line: 3 must be specified (it says line 3, but I believe that's
> because my CsvRecord class has the skipFirstLine=true)
>
> The CSV parsing seems to be handling commas within a field surrounded by
> double quotes since the 2nd line is okay. It's also handling escaping
> double
> quotes correctly within fields since the 3rd line is fine too.
>
> But the issue is when commas are present after an escaped double quote
> within a field that is surrounded by double quotes -- it seems to want to
> separate each comma into a new field when it should just be treating it as
> a
> single field.
>
> I'm using the latest version of Camel 2.18.3 and still observing this
> issue.
>
> My route is:
>
> from("sftp://
> [email protected]?sortBy=file:modified&antInclude=*.csv&password=xxxx")
>         .unmarshal()
>         .bindy(BindyType.Csv, ProductDeltaCsvDataModel.class) //throwing
> exception
> here
>         .to("direct:processCsv");
>
> This is my CsvRecord POJO class:
>
> @CsvRecord(separator = ",", skipFirstLine = true, quote = "\"", quoting =
> true)
> public class ProductDeltaCsvDataModel {
>
>         @DataField(pos = 1, required = true)
>         private String partNumber;
>
>         @DataField(pos = 2)
>         private String longDescription;
>
>         @DataField(pos = 3)
>         private String status;
>
>         //setters and getters
>         ...
> }
>
> I believe this to be a bug unless there is some configuration I need to
> set?
>
> Can someone confirm that this is a bug and how I go about logging this bug?
>
> Thanks!
> Sadiq
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Parsing-issue-with-unmarshal-and-bindy-csv-with-double-quotes-and-commas-in-a-single-field-tp5797871.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
-- 
Sent from my iPhone

Reply via email to