# Conditions randomization

**URL:** <https://discourse.psychopy.org/t/conditions-randomization/27259>\
**Category:** Builder\
**Tags:** randomization\
**Created:** [February 8, 2022, 10:14am UTC](https://discourse.psychopy.org/t/conditions-randomization/27259 "2022-02-08T10:14:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Milena](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Milena](https://discourse.psychopy.org/u/Milena)\
**Post date:** [February 8, 2022, 10:14am UTC](https://discourse.psychopy.org/t/conditions-randomization/27259/1 "2022-02-08T10:14:18Z")

</div>

Hi,

I’m new on Psychopy and I have a problem with my conditions randomization.

I have two excel file with 106 rows and I want that for one participant they select rows 0:52 in nutri1.xlsx and rows 53:102 in organo1.xlsx and for another rows 53:102 in nutri1.xlsx and rows 0:52 in organo1.xlsx.

Here the excel file  
[nutri1.xlsx](https://discourse.psychopy.org/uploads/short-url/z6tR4K0uO4aJ2UdzIuG8ma4q3tI.xlsx) (12.6 KB)  
[organo1.xlsx](https://discourse.psychopy.org/uploads/short-url/1nmbYBQO0WlX2SZcwyzu1aigtGU.xlsx) (10.7 KB)

My first loop

 ![loop](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/c/f/cfb1069f19d526007a69047091644ae45e9633ad.png)

I think I need to insert another loop but I don’t know what I’m suppose to put in this loop to do what I want …

If someone has an idea that would be great ! Thanks 🙂

(I’m French sorry for my English syntax)

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [February 8, 2022, 1:11pm UTC](https://discourse.psychopy.org/t/conditions-randomization/27259/2 "2022-02-08T13:11:22Z")

</div>

Hello Milena,

the numbers go in **Selected rows**. You need to distinguish the rows for the two groups. So do something along the following lines:

```auto
if int(expInfo['participant'])%2 == 0:
    startNutri = '0'
    endNutri = '52'
    startOrga = '53'
    endOrga = '102'
else:
    startNutri = '53'
    endNutri = '102'
    startOrga = '0'
    endOrga = '52'

rowsNutri = startNutri + ":" + endNutri
rowsOrga = startOrga + ":" + endOrga

```

This code uses the participant number (odd, even) to generate two groups of participants. Use whatever is best for your case. Refer with $rowNutri and $rowsOrga in **Selected rows** of the two loops to access the relevant rows.

Best wishes Jens

---

<div class="post-metadata">

**Author:** ![Milena](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Milena](https://discourse.psychopy.org/u/Milena)\
**Post date:** [February 10, 2022, 12:13pm UTC](https://discourse.psychopy.org/t/conditions-randomization/27259/3 "2022-02-10T12:13:54Z")

</div>

Hello Jens,

It works perfectly !

Thank you very much for your help 🙂

Best wishes Milena
