Okay, I got it to work! Thank you @dvbridges!
To summarize: use the TrialHandler to import the stimuli. This will need to be edited separately in python and JS; if you are in builder, it is easiest to use a python-only code component and a js-only code component.
You can see a working example here:
https://pavlovia.org/run/Aisa2/dictimport_test/html/
And the code here:
In the python code, the import looks like:
testfile = './html/resources/somefile.csv'
varNames = ['col1','col2','col3','etc']; # names of column headers in original file: this is optional, I think.
stimData = data.TrialHandler2(trialList= data.importConditions(testfile), nReps = 10, method='sequential', extraInfo= expInfo)
In the JS code, it looks like:
testfile = 'somefile.csv'
varNames = ["col1", "col2", "col3", "etc"];
stimData = new TrialHandler({
psychoJS: psychoJS,
nReps: 1, method: TrialHandler.Method.SEQUENTIAL,
extraInfo: expInfo, originPath: undefined,
trialList: testfile,
seed: undefined, name: 'stimData'
});
Then you access the file in a row/column fashion, like
stimData[0]['myColumnHeader']
Other notes from @dvbridges on the JS end:
// If you want to create two arrays for two types of condition,
// you can filter the list of objects based on a variable in conditions file
// e.g., column labelled "condition" for condition 0 and condition 1
cond0 = stimData.filter((trial) => trial['condition']==0)
cond1 = stimData.filter((trial) => trial['condition']==1)
// Now you can choose to shuffle your new arrays, or leave them sequential
util.shuffle(cond0)
Bonus note: if you want to select different slices of your newly-imported stimulus set, you will also need to do this in python/JS separately, using [start:end] in python and .slice(start, end) in JS.