Independently select parameters from conditions file

What are you trying to achieve?:
I have a conditions file with two parameters. Within each trial I want to randomly select an item from column A and randomly select an item from column B. The problem is that columns A and B are married and the content on a given row always appears together.

What did you try to make it work?:
I have searched the archives and tried various bits of code that have been suggested for similar problems over the years; however, these solutions are likely outdated, and I’m struggling with errors. I’m wondering whether there is now a simpler solution to this common issue.

The key is that one column needs to be preloaded or defined as an independent list. Have a look at my Independent Randomisation online demo

Thanks - I’ve tried this but I get the following error:
ValueError: invalid literal for int() with base 10: [content of one of my rows of colA]
(My colA contents are strings)

Check your spreadsheet for blank cells or rows.

What custom code might you have added which needs an integer?

I’ve just looked at the code you sent me.

You have:

listA.append(str(int(activity)))
# Use listA.append(colA) if colA is text

Your activity column contains text, so please try listA.append(activity)

Ah - yes, thanks so much for your help. That did fix it so it now runs, but the activities and times are all still appearing linked in the same way as in the excel file.

I also added a third column, activitytype, that notes the activity as cognitive or social. I do want activitytype to be married to activity, just in the output, so it is coded as whether each of those activities are cognitive or social. But I want the activities to be appearing with a random time rather than the time in the same row on the excel spreadsheet.

I tried to do this in two ways:

  1. preloading activity as listA and activitytype as listB
  2. preloading only time as listA

In either case, the result is the same, and on each trial, the activities appear with the same time as what is in their row on the spreadsheet.

You’ve preloaded activities into listA but aren’t using them.

In activity1 put the text as $thisA instead of $activity

Ah, right, yes! If I want the activity and activitytype linked (as in married to the one in the same row on the spreadsheet), but the time randomised, should I preload both activity and activitytype or preload time?

Based on “I want the activity and activitytype linked (as in married to the one in the same row on the spreadsheet), but the time randomised” I would preload the time instead of the activity

Thanks a million. All sorted now.