Quotation marks in sentence stimuli cause errors in output csv

OS: Mac OS
PsychoPy version: 3.0.0b11
Standard Standalone? (y/n): Y

What are you trying to achieve?: I am currently building an experiment where I am presenting a story to participants. The story is saved in an .xlsx file, where each sentence is on a separate line, which is then read into a loop in Builder and presented onscreen. It looks something like this:

So, each sentence from the Story variable is presented onscreen the participant, and they press a button to proceed. For some reason, whenever the sentence contains a quotation mark, the resulting row of data in the output csv is shifted or missing entirely. You can see an example below, for the sentence “Kan, kan.”:

Does anyone know how to get around this issue? Ideally, the entire sentence, which in this example was “Kan kan.”, should be saved to a separate row of the csv just like other sentences.

Also, it’s important to note that not all quoted sentences begin and end with a quotation mark. Some will have a quote at the beginning followed by text outside of quotations. For example:

  • “English,” I said, raising my voice.

Others have a quotation spanning multiple sentences. For example:

  • "You knew this was going to happen some day.
  • What did you expect?"

Any sentence that includes a quotation mark will not be properly saved in the output csv. If anyone has any advice about how to fix this, I would really appreciate it! Keeping the quotation marks is key, as they are an important feature of the original narrative.

Thanks!

B

Found a quick fix! Replacing any instance of quotation marks ( " ) with two single quotes ( ‘’ ) seemed to fix the issue, while keeping the text pretty much identical visually (at least with Arial font) .

B

Hi, the problem arises because the quotation marks are interpreted by Python as the end of the string (the text). For more explanation, see, e.g., here. To tell Python that they’re part of the text, you could put backslashes in front of each quotation mark in the sentences in the XLSX file, e.g. \"Kan, kan.\". It’ll be easy using the search (") and replace (\") function.