You have four fields in the fourth row hence the error.
On Wed, Apr 19, 2017 at 7:10 AM, sadiq [via Camel] <
[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
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Parsing-issue-with-
> unmarshal-and-bindy-csv-with-double-quotes-and-commas-in-a-
> single-field-tp5797871.html
> To start a new topic under Camel - Users, email ml+s465427n465428h31@n5.
> nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
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-tp5797871p5797940.html
Sent from the Camel - Users mailing list archive at Nabble.com.