Hey!
I would keep the loop condition like this. Eventually you want to have the concrete file BlockA.xlsx or BlockB.xslx in your loop condition. Now you just decompose the name name as you did in constant parts and flexible parts. The constant parts are the strings “Block” and “.sxls”. The variable part is the condition variable and this should be filled out with the strings “A” or “B”. The question is where you introduce this variable and what determines the Value they have. In our experiment we inserted a participant counter that told us, which participants number the participant has without having the participant fill out anything. You could do the same and then make an assignement with code:
if participantsnumber <= x:
condition == ‘A’
else:
condition == ‘B’
Having defined the condition like this, your loop condition should be able to add the flexible and variable components together and search for either BlockA.xlsx or BlockB.xslx.
For the participants counter we created a python file with one value in it: 0. Then in the beginning of the experiment we read in the file, create a variable p_number and assign the last line of the python file to it. Then the number for the current participant is created by making a new variable p_number_pilot and assigning p_number and adding +1 to it. Finally we update the python folder with the current participants number by writing it back into the file. That’s the code:
# Read out participant number from a file
f = open('p_number_pilot.txt', 'r')
p_number = f.readline()
f.close()
# Update the number for the new participant
p_number_pilot = int(p_number) + 1
# Update participant number in the file
f = open('p_number_pilot.txt', 'w')
f.write(str(p_number_pilot))
f.close()