# Random selection from two separate blocks (.xlsx files)

**URL:** <https://discourse.psychopy.org/t/random-selection-from-two-separate-blocks-xlsx-files/9010>\
**Category:** Builder\
**Tags:** randomization\
**Created:** [September 11, 2019, 9:06am UTC](https://discourse.psychopy.org/t/random-selection-from-two-separate-blocks-xlsx-files/9010 "2019-09-11T09:06:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![catalinat](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@catalinat](https://discourse.psychopy.org/u/catalinat)\
**Post date:** [September 11, 2019, 9:06am UTC](https://discourse.psychopy.org/t/random-selection-from-two-separate-blocks-xlsx-files/9010/1 "2019-09-11T09:06:49Z")

</div>

Hi,  
I am new to psychopy and was successful with a simple demo experiment. Now I have to develop something more advanced and have come across an issue. I hope I am not cross-posting but I couldn’t find anything that could solve this. I thank anyone who would have some advise! (For more information, I am attaching a screenshot of builder and the code of my experiment.)

**OS** (e.g. MacOs High Sierra 10.13.6):  
**PsychoPy version** (e.g. 3.1.5):

_What are you trying to achieve?:_\*  
I have 8 words as sound stimuli in 2 conditions (Set1 and Set2). This means 8 times the same word but with an acoustic variation (8x2=16). The aim is that each participant is presented to all 8 words but to a random condition (=8 words, 4 are from Set1 and 4 from Set2). This should be also random for a larger set of participants.

**What did you try to make it work?:**  
I have followed all steps found in [Randomly selecting a subset of 5 excel rows from groups of 10 rows on each trial](https://discourse.psychopy.org/t/randomly-selecting-a-subset-of-5-excel-rows-from-groups-of-10-rows-on-each-trial/5098).

Hence, I have:  
two inner loops (trial\_1 and trial\_2)  
one outer loop (outer\_loop)  
two .xlsx files (teststimuli.xlsx and teststimuli2.xlsx)  
a bit of code for randomisation.

**What specifically went wrong when you tried that?:**  
The experiment breaks down and the stimuli are not random  
When I run the experiment:  
Introduction is ok  
Set1 is presented 4 times  
Set2 is presented 4 times  
It breaks down and then I get this error message:

" ######## Running: /Users/catalinat/Desktop/Ex\_Aix/JeuDeMots\_lastrun.py #########  
2019-09-11 10:52:12.374 python[2350:38386] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)  
Traceback (most recent call last):  
File “/Users/catalinat/Desktop/Ex\_Aix/JeuDeMots\_lastrun.py”, line 448, in   
trialList=data.importConditions(control\_blocks.pop(), selection=choice(8, size=4, replace=False)),  
IndexError: pop from empty list

######## Running: /Users/catalinat/Desktop/Ex\_Aix/JeuDeMots\_lastrun.py #########  
2019-09-11 11:00:10.636 python[2396:40529] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)  
Traceback (most recent call last):  
File “/Users/catalinat/Desktop/Ex\_Aix/JeuDeMots\_lastrun.py”, line 448, in   
trialList=data.importConditions(control\_blocks.pop(), selection=choice(8, size=4, replace=False)),  
IndexError: pop from empty list

 ![23%20am](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/8/b/8b0437aa3e732d57789225357c4cdf8def6bd15d.jpeg)"[JeuDeMots.psyexp](https://discourse.psychopy.org/uploads/short-url/9H2cSfuFJlQI8qOLsvfDyMSv9PR.psyexp) (34.7 KB)

---

<div class="post-metadata">

**Author:** ![kirsten](https://avatars.discourse-cdn.com/v4/letter/k/ba8739/32.png) [@kirsten](https://discourse.psychopy.org/u/kirsten)\
**Post date:** [September 11, 2019, 9:46am UTC](https://discourse.psychopy.org/t/random-selection-from-two-separate-blocks-xlsx-files/9010/2 "2019-09-11T09:46:46Z")

</div>

Hi Catalint,  
I’m not able to work out why your experiment isn’t working (been a long time since I was working in PsychoPy- and I’m still quite a beginner myself). However due to the amazing support I have received in the past I am keen to help if I can. I’m happy to share files with you if that might help? Anyway welcome to the community.  
Kirsten.

---

<div class="post-metadata">

**Author:** ![catalinat](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@catalinat](https://discourse.psychopy.org/u/catalinat)\
**Post date:** [September 11, 2019, 12:06pm UTC](https://discourse.psychopy.org/t/random-selection-from-two-separate-blocks-xlsx-files/9010/3 "2019-09-11T12:06:49Z")

</div>

> [@catalinat](#):
>
> IndexError: pop from empty list

Hello Kerstin,  
I just saw in [Sequence of 4 random events followed by a rating event as a block which will be looped through for all stimuli](https://discourse.psychopy.org/t/sequence-of-4-random-events-followed-by-a-rating-event-as-a-block-which-will-be-looped-through-for-all-stimuli/6446) that there was a similar issue but no one ever got back to him ☹

I have to run the experiment on another computer and tried it on a windows machine. But there is the same issue. Do you still have psychopy 1.9.3? Could you run my code with some dummy sound stimuli? I can upload the .xlsx files. [teststimuli.xlsx](https://discourse.psychopy.org/uploads/short-url/1VVPLfG45fU9ewVOtPTV3KxDRxc.xlsx) (8.7 KB) [teststimuli2.xlsx](https://discourse.psychopy.org/uploads/short-url/3ZxKuPWJZNTG0km0L3ucZbvz3Wu.xlsx) (8.7 KB)
