In the new release, 2023.2.0, ExperimentHandler.addData()
gets a new row
argument so you can add data to a previous entry.
But for the life of me, I can’t figure out how to get the current row number (so that, e.g., you could add data to the previous row).
Any suggestions for accessing the current row number?
Hello,
would not yourloopname.thisN do the trick?
Best wishes Jens
Unfortunately, I don’t think thisN
will work.
If I’m understanding the ExperimentHandler.addData()
documentation correctly, the row argument refers to the row in the data file.
For some context, I’m trying to have a key press on trial n show up in the data file in the row for trial n-1.
[I’ve edited the title of this thread to hopefully be a bit more clear]
Hello,
well, the following toy-program displays the thisN. I wasn’t talking about addData
thisN.psyexp (7.4 KB)
Best wishes jens
Thanks @JensBoelte. That’s helpful, but doesn’t quite solve my use case. Much appreciated anyway!
I figured out a sort of kludgey way to make this work, but I’m not confident it is reliable at all. I’d really appreciate any comments.
This code gets the total number of Entries
in the data file, then calls thisExp.addData
with the row argument of data_length-2
(I used minus 2, not minus 1, since I had this code run in End Routine, which seems to be after the number is incremented).
data_length = len(thisExp.getAllEntries())
if data_length > 1:
thisExp.addData(name = "marked_clicked_in_next_item",
value=1, row=data_length-2)
Any suggestions or comments about whether this is a totally unreliable method would be appreciated.
Here is a dummy experiment that uses this code, plus a sample results file (and the stimlist):
183995_Mark previous trial_2023-08-04_10h52.10.923.csv (3.3 KB)
mark_prev_trial.psyexp (21.9 KB)
stimlist.csv (285 Bytes)
If you hit the button on trial n, the data file adds a 1
to the datafile row for n-1 in the marked_clicked_in_next_item
column.
Again, I’m very unsure whether this is reliable, so anyone reading this in the future, use at your own risk!
Hello,
Sorry, I misread your post. You’re right, my approach won’t help.
Best wishes Jens