Trying to use different excel columns based on participant number

So Im trying to display text using a different column of data depending on the provided participant number.

Columns are set up as “Participant1” “Participant2” etc.

I’m just using a small tidbit of code in a text stimuli presentation (not the code builder)

$(“Participant” + $expInfo[‘participant’])

It is getting the participant number perfectly fine, and combining them correctly, but then it isn’t using them to access the excel file, it is just printing them as a string(as Participant1, Participant2 etc). It is almost like it is ignoring the “$” entirely.

I’m new to this, so I’m sure its something simple I am overlooking.

You are almost there. You have correctly constructed a string of characters but that’s all it is: a string of characters. i.e. the string 'Participant1' is not the same as the variable name Participant1.

Fortunately, Python is a language that allows you to evaluate a string of characters to turn it into the equivalent variable name. So your expression should include the eval() function:

$eval(“Participant” + $expInfo[‘participant’])
1 Like