Experiment crashes after the loop ends

OS (e.g. Win10): MacOS Sonoma 14.4
PsychoPy version (e.g. 1.84.x): v2023.2.3
**Standard Standalone? y ** If not then what?:
What are you trying to achieve?:

Hello! I am trying to create an experiment where the task is to tap along to a 30s long rhythm sequence using the spacebar. There are meant to be 6 conditions with 4 repetitions. I am interested in the reaction time of the keypresses and the experiment runs fine until the final trial of the loop. It just crashes.

What did you try to make it work?:

I added this code

Begin Experiment

response_clock = core.Clock() # Create a clock object for measuring response time

Each Frame

keys = event.getKeys([‘space’]) # Check for spacebar press
if ‘space’ in keys: # Assuming ‘space’ is the key for the participant’s response
reaction_time = response_clock.getTime() # Get the reaction time
print(“Reaction Time:”, reaction_time) # Print the reaction time

What specifically went wrong when you tried that?:
Include pasted full error message if possible.

I get these errors:

ioHub Server Process Completed With Code: 0
File “/Users/andreachavez/Documents/PsychoPy/RPE/RPECoded_lastrun.py”, line 1648, in
run(
File “/Users/andreachavez/Documents/PsychoPy/RPE/RPECoded_lastrun.py”, line 1317, in run
trials.saveAsText(filename + ‘trials.csv’, delim=‘,’,
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/data/base.py”, line 201, in saveAsText
dataArray = self._createOutputArray(stimOut=stimOut,
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/data/trial.py”, line 444, in _createOutputArray
tup = eval(strVersion) # convert back to a tuple
File “”, line 1
[, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ]
^
SyntaxError: invalid syntax
################# Experiment ended with exit code 1 [pid:4581] #################

Can anyone help please?

Hi,
The error may be due to incorrect data formatting or structure during saving. Try to verify your data-saving logic and format variables and strings.
Hope this helps.