Apache Camel - invalid char between encapsulated token and delimiter

20 Views Asked by At

I am getting the below sample csv response from Salesforce.

"Id","Success","Created","Error"
"","false","false","UNABLE_TO_LOCK_ROW:unable to obtain exclusive access to this record or 100 records: a6F3s000000UDLgEZZ
"","false","false","UNABLE_TO_LOCK_ROW:unable to obtain exclusive access to this record or 100 records: a6F3s000000UDLgEZZ

As I tried to unmarshall to List<List> using the below code in Apache Camel

CsvDataFormat inFormat = new CsvDataFormat(",");
inFormat.setRecordSeparator("\r\n");


from("file://" + dropFolder + "?delay=" + dropFilePollDelay + "&preMove=.processing&move=../.camel&moveFailed=../.error")
    .routeId("CSVTestRoute")
    .unmarshal(inFormat)
        .multicast()
            .parallelProcessing()
              .to("direct:processCSVSuccesses")
      .end();


 from("direct:processCSVSuccesses")
  .routeId("processCSVSuccesses")
  .log("processCSVSuccesses => ${body}");

I am getting the below error.

java.lang.IllegalStateException: IOException reading next record: java.io.IOException: (line 3) invalid char between encapsulated token and delimiter
    at org.apache.commons.csv.CSVParser$CSVRecordIterator.getNextRecord(CSVParser.java:536) ~[commons-csv-1.6.jar:1.6]
    at org.apache.commons.csv.CSVParser$CSVRecordIterator.hasNext(CSVParser.java:546) ~[commons-csv-1.6.jar:1.6]

Please note that in the record the value "UNABLE_TO_LOCK_ROW:unable to obtain exclusive access to this record or 100 records: a6F3s000000UDLgEZZ is not inside the double quotes properly.

How to resolve this problem?

0

There are 0 best solutions below