# Unique conditions file for each participant based on participant number in Builder

**URL:** <https://discourse.psychopy.org/t/unique-conditions-file-for-each-participant-based-on-participant-number-in-builder/4359>\
**Category:** Builder\
**Tags:** randomization\
**Created:** [April 16, 2018, 2:55pm UTC](https://discourse.psychopy.org/t/unique-conditions-file-for-each-participant-based-on-participant-number-in-builder/4359 "2018-04-16T14:55:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cesco](https://avatars.discourse-cdn.com/v4/letter/c/97f17d/32.png) [@Cesco](https://discourse.psychopy.org/u/Cesco)\
**Post date:** [April 16, 2018, 2:55pm UTC](https://discourse.psychopy.org/t/unique-conditions-file-for-each-participant-based-on-participant-number-in-builder/4359/1 "2018-04-16T14:55:23Z")

</div>

Hi all,

I am using PsychoPy to present a questionnaire to my participants. More specifically, they do half a questionnaire with randomly selected items before a session in a different program, and they do the remaining items afterward.

With Python, it was reasonably straight forward to generate these lists beforehand, so now I have files such as ‘questionnaireA20.csv’ and questionnaireB20.csv’, where 20 is the participant number. I now have a version A and B of the .psyexp file, and let’s take the A-file as an example. The idea is that the A-file imports the A-list belonging to the participant number.

I attempted to achieve this by using the following code at “Begin Experiment”:  
`trialList=data.importConditions('questionnaireA'+expInfo['participant']+'.csv')`

Which does not return an error and the print command reads exactly what I would expect it to.

However, the problem seems to lie with the other elements in the flow (as the Conditions field in Properties is now empty). On the screen, I want to present text as defined by a column in the conditions file, so I call it with `$TextLeft` in the builder, which is one of the headers.

This results in a NameError, because the name ‘TextLeft’ is allegedly not defined. And part of me can see how that is obvious, but not obvious enough to solve it.

Is there a way to circumvent it?

(I am currently using the Python 3 version even though I have more experience with 2.7. But that’s not a big deal, just takes a little longer with sorting the grammar/syntax). I’m not afraid of using code but I would like to be able to keep it all in the Builder because of reasons.

Many thanks in advance!

---

<div class="post-metadata">

**Author:** ![jderrfuss](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jderrfuss/32/5245_2.png) [@jderrfuss](https://discourse.psychopy.org/u/jderrfuss)\
**Post date:** [April 17, 2018, 7:42pm UTC](https://discourse.psychopy.org/t/unique-conditions-file-for-each-participant-based-on-participant-number-in-builder/4359/2 "2018-04-17T19:42:38Z")

</div>

Just to clarify: Is there a specific reason why you don’t simply put the file name (i.e., `$'questionnaireA'+expInfo['participant']+'.csv'`) in the `Conditions` field of the loop around your main trial routine?

Jan

---

<div class="post-metadata">

**Author:** ![Cesco](https://avatars.discourse-cdn.com/v4/letter/c/97f17d/32.png) [@Cesco](https://discourse.psychopy.org/u/Cesco)\
**Post date:** [April 18, 2018, 8:08am UTC](https://discourse.psychopy.org/t/unique-conditions-file-for-each-participant-based-on-participant-number-in-builder/4359/3 "2018-04-18T08:08:55Z")

</div>

Beats me. probably because it almost seemed _too_ easy. \*Bows head in shame.

(To be fair, when I tried something similar on a different OS before, the field would return to being blank. But to be even fairer, that was probably due to a syntax mishap).

Thank you @jderrfuss.
