[open] Use .csv in lieu of loop "spreadsheet"
Hi,
I've seen several responses which do "nearly" what I want so please excuse me for not being able to work it out for myself:
I'd like to use a .csv (or other text file) as a "drop-in replacement" for the variable data in a "loop" (so that I can edit some complex materials externally). Following this discussion it seems easy to read stuff in and transfer it to experimental variables, but if I understand the example correctly it had six items hard-coded in?
What I'd like to do is generalise the solution into a loop, so that I can read in an arbitrary number of items into "setcycle" variables without having to write repetitive and error-prone code. And for some reason, a sensible solution is eluding me... Any pointers hugely appreciated!
--MC
Comments
I had to do something not too dissimilar recently, which I've detailed here.
For your case, I would try adjusting the code at the bottom of the page to something along the lines of this (although I haven't tested this in OpenSesame yet):
You can then use the example
loopobject in the link to use these loaded variables.Edit: Be aware that any numerical variables will be saved as strings using this method. OpenSesame might deal with this gracefully and you won't need to worry, but otherwise you may need to use the python
int()function:Again, without testing this, I just don't know.
Hi, this looks great, thanks Eoin! I'll have a play and post here when done.
--MC