Adding a newly created variable to the output file

OS (e.g. Win10):
PsychoPy version (v2023.2.3):
**Standard Standalone? YES

Hello. I hope somoene can help me.
Using the builder, I’ve written some code to create a new variable called
“numberOfCorrectTrails”. That code is working.

At the end of the experiment, I’d like to simply write the value of that variable to the end of the output data file (the Excel file that typically lands in the data folder). I’ve used this code at the end of my code block:

data.ExperimentHandler.addData(‘numberOfCorrectTrails’, numberOfCorrectTrails)

This code generates an error that says I’m missing an argument: “Value”.

I thought I was handing the command both a string for the output variable name (‘numberOfCorrectTrails’…in single quotes), and a value for that variable (numberOfCorrectTrials).

Apparently, the code above is not being interpreted as the command’s “value” argument.

I welcome any suggestions for how to modify the code above to write this newly created variable into the experiment’s Excel file.

Thank you!

I always use thisExp.addData

Check that your single quotes are 'dumb' not ‘smart’

1 Like

That worked! Specifically, your suggestion to use thisExp.addData got me around the error I had been receiving. Thank you wakecarter!