In a code component, I want to conditionally select one of my columns (to refer to my stim) from my conditions xlsx file. If I was doing this in a Text component, I would just use the $ to access that column but I can’t use this in the code component (I tried this below and it doesn’t work and I know this isn’t correct syntax: left2 = “$left1”).
So each header of your conditions file is a variable name. When you use these variables to set parameters of something in the builder view (e.g. the writing in the text) you need to use the “$” to say you are referring to a variable (in your example “left"). However, when you are referring to variables in code snippits there is no need to say you are looking for a variable (this is assumed when coding), so you can just use the variable/header name without the "” sign (i.e. “left”).
Try this:
left1 = None
left2 = None
right1 = None
right2 = None
if expInfo['Order'] == "A":
left1 = "WOMAN"
right1 = "MAN"
left2 = left
right2 = right
elif expInfo['Order'] == "B":
left1 = left
right1 = right
left2 = "MAN"
right2 = "WOMAN"
note that the only difference from your code is that the “$” is not used.
This error means that the variable is not defined (and is probably the most common error in python, so good to get accustomed with!).
The usual suspects to check are that the column header of your conditions file is spelt identically to how it it spelt in the code snippet (including any pesky spaces/differences in capitalisation) and that your trials loop has the correct conditions file linked .