I am trying to read the result from my Bulk API job I have successfully submitted to Salesforce.

When I call my CSVReader.nextRecord() I get the following error:

Exception in thread "main" com.sforce.async.CSVReader$CSVParseException: Found unescaped quote. A value with quote should be within a quote

My code looks as follows:

 CSVReader rdr = new CSVReader(connection.getBatchResultStream(job.getId(), b.getId()));
        List<String> resultHeader = rdr.nextRecord();
        int resultCols = resultHeader.size();

        List<String> row;
        while ((row = rdr.nextRecord()) != null) {
            Map<String, String> resultInfo = new HashMap<String, String>();
            for (int i = 0; i < resultCols; i++) {
                resultInfo.put(resultHeader.get(i), row.get(i));
            boolean success = Boolean.valueOf(resultInfo.get("Success"));
            boolean created = Boolean.valueOf(resultInfo.get("Created"));
            String id = resultInfo.get("Id");
            String error = resultInfo.get("Error");
            if (success && created) {
                System.out.println("Created row with id " + id);
            } else if (!success) {
                System.out.println("Failed with error: " + error);

Any suggestions how I can fix this?

  • 1
    The error suggests the CSV returned by getBatchResultStream() is invalid. Are you able to check the string that is returned in the Stream? Jan 8, 2013 at 22:43
  • I am seeing the same issue today. Could you suggest what solved this problem for you? Please share solution. Thanks!
    – Maha
    Nov 30, 2016 at 1:18

1 Answer 1


I've seen this issue before, if you copy the CSV file's text into notepad, and then save it using the ASCII format, it will ensure that you're using character code 39 and not 96:

Check out this link to view the different character codes: http://www.asciitable.com/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .