Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
The error suggests the CSV returned by getBatchResultStream() is invalid. Are you able to check the string that is returned in the Stream? – Daniel Ballinger Jan 8 '13 at 22:43
up vote 4 down vote accepted

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:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.