# How easy is it to distribute a long list of trials among participants?

**URL:** <https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210>\
**Category:** Builder\
**Tags:** pavlovia\
**Created:** [July 23, 2021, 6:14pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210 "2021-07-23T18:14:47Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Sidhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_sidhu/32/14484_2.png) [@David\_Sidhu](https://discourse.psychopy.org/u/David_Sidhu)\
**Post date:** [July 23, 2021, 6:14pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/1 "2021-07-23T18:14:47Z")

</div>

Here is my situation. I have ~10,000 potential trials. I would like to have them each responded to twice.

I thought to do this by creating one big conditions file with all 10,000 trials in a random order, and then all 10,000 again in a different random order.

I would like to do something like: give participant 1 rows 1:100, participant 2 rows 101:200 and so on.

I figure this should be doable, by somehow incrementing participant number, and have the rows that are presented be some function of the participant number?

I’m not asking for an exact explanation on how to do this, but I wanted to be sure that this was in the realm of possibility before I started really looking into it.

Participants will be taking part on Pavlovia.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [July 23, 2021, 10:06pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/2 "2021-07-23T22:06:36Z")

</div>

At the moment your best option is to use my VESPR Study Portal and either set up 100 groups or use the consecutive participant number (which doesn’t account for abandonment).

---

<div class="post-metadata">

**Author:** ![David\_Sidhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_sidhu/32/14484_2.png) [@David\_Sidhu](https://discourse.psychopy.org/u/David_Sidhu)\
**Post date:** [November 12, 2021, 6:13pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/3 "2021-11-12T18:13:41Z")

</div>

@wakecarter Sorry, I never thanked you for the reply!

I’m wondering if it’s still the case that this is the easiest way to do this? I should add that I’ll be running the study on Pavlovia.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [November 12, 2021, 9:14pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/4 "2021-11-12T21:14:34Z")

</div>

Yes, the [VESPR Study Portal](https://moryscarter.com/vespr/portal/) is still the best way to allocate to multiple groups while taking into account non-finishers.

There’s a link to a video, a post on this forum and some slides at the bottom of the [admin page](https://moryscarter.com/vespr/portal/admin/).

---

<div class="post-metadata">

**Author:** ![David\_Sidhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_sidhu/32/14484_2.png) [@David\_Sidhu](https://discourse.psychopy.org/u/David_Sidhu)\
**Post date:** [February 11, 2022, 10:05pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/6 "2022-02-11T22:05:07Z")

</div>

Thanks so much! I watched the video and it seems like exactly what I would like!

I’m now trying to implement it in an experiment. I’ve done so by having multiple Excel files (i.e., one for each condition). Then in my loop, I have it set to choose a specific Excel file based on the group number. To do this, I have code at the beginning of the experiment like this:

`theGroup = expInfo["Group"]`

And them in my Loop, the conditions file is called:

`$"Group" + theGroup + ".xlsx"`

This works great when I run it on my computer, but when I try to upload it to Pavlovia, I get this error. It seems like it doesn’t like only having Group defined when a person begins the experiment? Do you have any advice on how to handle this (with the eventual goal of then interfacing with VESPR)?

```auto

Traceback (most recent call last):
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 829, in findPathsInFile
  File “<string>”, line 1, in <module>
NameError: name ‘theGroup’ is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/openpyxl/reader/excel.py”, line 121, in _validate_archive
  File “zipfile.pyc”, line 1131, in __init__
  File “zipfile.pyc”, line 1198, in _RealGetContents
zipfile.BadZipFile: File is not a zip file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/builder/builder.py”, line 1344, in onPavloviaSync
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/builder/builder.py”, line 793, in fileExport
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 74, in generateScript
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 247, in compileScript
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 219, in _makeTarget
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 254, in writeScript
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/flow.py”, line 309, in writeFlowSchedulerJS
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 877, in getResourceFiles
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 843, in findPathsInFile
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 860, in findPathsInFile
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/data/utils.py”, line 365, in importConditions
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/openpyxl/reader/excel.py”, line 174, in load_workbook
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/openpyxl/reader/excel.py”, line 124, in _validate_archive
  File “zipfile.pyc”, line 1131, in __init__
  File “zipfile.pyc”, line 1198, in _RealGetContents
zipfile.BadZipFile: File is not a zip file

```

* * *

It would also be nice to be able to have one Conditions file, and present a subset of rows based on Group Number (i.e., instead of having multiple conditions files). I wonder if this is possible?

I’ve tried doing something like this. Having this code run before the experiment:

```auto
theGroup = expInfo["Group"]
conditions = data.importConditions(Conditions.xlsx’)
Group1 = conditions[0:3]
Group2 = conditions[4:7]

```

And then, in my loop, setting Selected rows to: `$"Group" + theGroup`

But it doesn’t seem like this is correct.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 11, 2022, 11:37pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/7 "2022-02-11T23:37:09Z")

</div>

Code is case sensitive. Try

`theGroup = expInfo['group']`

---

<div class="post-metadata">

**Author:** ![wen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wen/32/30795_2.png) [@wen](https://discourse.psychopy.org/u/wen)\
**Post date:** [February 13, 2022, 6:33am UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/8 "2022-02-13T06:33:47Z")

</div>

You might want to try nesting three files.such as condition1.xlsx condition2.xlsx and condition3

---

<div class="post-metadata">

**Author:** ![David\_Sidhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_sidhu/32/14484_2.png) [@David\_Sidhu](https://discourse.psychopy.org/u/David_Sidhu)\
**Post date:** [February 14, 2022, 7:16pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/9 "2022-02-14T19:16:34Z")

</div>

Thanks for getting back to me! I tried using lower case for “group” but it doesn’t help.

Also, when I take a look at the variable in my code it is upper case:

`expInfo = {'participant': '', 'session': '001', 'Group': ''}`

---

<div class="post-metadata">

**Author:** ![David\_Sidhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_sidhu/32/14484_2.png) [@David\_Sidhu](https://discourse.psychopy.org/u/David_Sidhu)\
**Post date:** [February 14, 2022, 7:16pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/10 "2022-02-14T19:16:54Z")

</div>

Sorry, I’m not sure what you mean exactly?

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 14, 2022, 8:03pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/11 "2022-02-14T20:03:03Z")

</div>

Personally, I prefer to use the selected rows field in the loop rather than have multiple spreadsheets to manage.

---

<div class="post-metadata">

**Author:** ![David\_Sidhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_sidhu/32/14484_2.png) [@David\_Sidhu](https://discourse.psychopy.org/u/David_Sidhu)\
**Post date:** [February 14, 2022, 10:40pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/13 "2022-02-14T22:40:36Z")

</div>

Okay, I will go this route! Is there any chance you could recommend a guide doing this sort of thing? (I.e., having rows selected based on group number)

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 14, 2022, 11:19pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/14 "2022-02-14T23:19:46Z")

</div>

If your expInfo variable is called group then you could have the following in a Begin Experiment code tab:

```auto
useRows = '' # Required to prevent an undefined error online
if expInfo['group'] == '1': # Note that expInfo values are strings.
     useRows = '0:4' # First four conditions
elif expInfo['group'] == '2':
     useRows = '4:8' # Second four conditions

```

Then in your loop set selected rows to $useRows

---

<div class="post-metadata">

**Author:** ![David\_Sidhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/david_sidhu/32/14484_2.png) [@David\_Sidhu](https://discourse.psychopy.org/u/David_Sidhu)\
**Post date:** [February 15, 2022, 6:11pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/16 "2022-02-15T18:11:42Z")

</div>

Thank you! It is working perfectly!

Just for my own understanding, is `useRows = ''` necessary because we have to create a variable before setting its value?

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 15, 2022, 7:17pm UTC](https://discourse.psychopy.org/t/how-easy-is-it-to-distribute-a-long-list-of-trials-among-participants/24210/17 "2022-02-15T19:17:49Z")

</div>

I think that the issue is one of scope. It seems that if a variable is first declared inside brackets (such as a loop or conditional clause) then it can’t be used outside those brackets. However, if it is given a value outside then it can tale values outside and inside.

You could set it to the rows for group 1 and only change that value for other groups.
