# Conditional excel file not read into nested loop

**URL:** <https://discourse.psychopy.org/t/conditional-excel-file-not-read-into-nested-loop/28813>\
**Category:** Online experiments\
**Created:** [April 25, 2022, 11:40am UTC](https://discourse.psychopy.org/t/conditional-excel-file-not-read-into-nested-loop/28813 "2022-04-25T11:40:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nadescha\_Trudel](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/nadescha_trudel/32/33922_2.png) [@Nadescha\_Trudel](https://discourse.psychopy.org/u/Nadescha_Trudel)\
**Post date:** [April 25, 2022, 11:40am UTC](https://discourse.psychopy.org/t/conditional-excel-file-not-read-into-nested-loop/28813/1 "2022-04-25T11:40:21Z")

</div>

URL of experiment: [spacegame\_real\_beforemergence [PsychoPy]](https://run.pavlovia.org/DevComPsy/spacegame_fullexperiment)

Description of the problem:  
Hi, I am running quite a complicated experiment that has several nested loops and jumps across routines – therefore I hestiated to post here, because I believe that it might be tricky to describe it fully. Anyway, here it is:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/8/e84d23bfbe5ed345b20ef0a96756fc17d7f5d0ed.png)

I am reading an excel file into each loop: opt\_exp\_loop and the loop called exp\_loop. Depending on different conditions that need to be fulfilled by the participants, the name of each excel file changes in order to read in a new excel file for the nex time around.  
It works out with the inner loop (opt\_exp\_loop) which calls four stimuli correctly from the correct file.  
However, it does not work for the outer loop (exp\_loop) even though the correct excel file name is printed into the logfile. This problem only occurs online only but runs smoothly locally. I have tried to integrate the new excel file at multiple instances:

a) at the the ‘checkswitch’ routine in the ‘each frame’ tab  
b) in the ‘finish\_exp’ routine in the ‘begin each routine’ tab  
c) pred\_stim\_exp in the ‘each frame’ tab

So this means, I am checking stuff in ‘checkswitch’ and according to some conditions met, it should change the name of the excel file for the next time around → which would affect the path for the stimuli that are being read for ‘pred\_stim\_exp’ routine.

The details of the loops look like this (this is the one not working:)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/9/5/953a2e4e5344e0dda6864bd82f8ebdd67c514950.png)

I would be super helpful for any help as I have been trying to solve this now for a long time. If you need more information or access to the experiment, do let me know.

Thanks,  
Nadescha

---

<div class="post-metadata">

**Author:** ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)\
**Post date:** [April 25, 2022, 2:52pm UTC](https://discourse.psychopy.org/t/conditional-excel-file-not-read-into-nested-loop/28813/2 "2022-04-25T14:52:53Z")

</div>

I wonder if you’d be able to create a “Minimal Working Example” of the problem. Create a new study with just the minimal loops and components needed to demonstrate the issue and share that with us - there’s rather a lot in your full study that we’d need to work through to get to the issue. That would help us help you quicker 🙂

many thanks  
Jon
