Randomise row order of input spreadsheet

I have a study which uses a spreadsheet, with one column featuring a list of 100 sounds to be played, once each, over 4 blocks, i.e. 25 sounds per block.

What I want to do is to randomly shuffle all the sentences from the spreadsheet first, and then play them over the four blocks. I’m struggling to make this happen just using the GUI (all I can currently do is play the first 25 sentences as they appear in the spreadsheet, in block 1; the second 25 sentences as they appear in the spreadsheet, in block 2, etc).

I’m guessing that I need some code to read in the spreadsheet and then randomly shuffle the items in it, with the subsequent array then being used by the each of the four blocks. Could someone please let me know how this can be achieved, or point me in the right direction please?

Several of my online demos do this (Independent Randomisation, PM N-Back, PM Time and Trial Switching)

However, your solution could be even simpler, if you have one block and then a routine that ends if trials.thisN%25 > 0 and can change the parameters for the following trials.

Hello, thanks for pointing me in the direction of the online demos. I’ve looked at those that you referred me to, and have adapted the code to work in my experiment…but unfortunately I still can’t get it to work. I’ve now made an ultra-simple version of the experiment that just has 8 items on the spreadsheet, for simplicity. By way of background, I am trying to read in the spreadsheet using code, then shuffle the order of the items, with code, and then play the shuffled order across two blocks sequentially. I attach here in case you or anyone has time to see where I might be going wrong. Many thanks.
conditions.xlsx (9.6 KB)
untitledv5.psyexp (18.8 KB)

I’m getting the error

for row in myData.trialList:
NameError: name ‘myData’ is not defined

Is that the error you’re getting? That’s caused because you read the spreadsheet in Begin Routine but use it in Begin Experiment.

I note that you are using selected rows in your two loops which won’t work when you aren’t pointing to a spreadsheet.

Hello, yes that’s the error I was getting. I see that I should have read the spreadsheet and used the spreadsheet in Begin Routine. I’ve now done that thank you. The problem I now have is that in the actual trial loop I have ‘NameError: name ‘thisA’ is not defined’. I’m thinking that it should be defined, since I define it at that Begin Routine (using information from code established in the previous routine). Do you know what I’m doing wrong there?
untitledv6.psyexp (19.2 KB)

Thanks for letting me know that I can’t use selected rows in the two loops because they’re not pointing to a spreadsheet.