Hello, I am trying to log the results of an experiment to the JS console using something straightforward as
let csv = psychoJS.experiment.getResultAsCsv();
console.log(‘CSV_’+csv+‘_ENDCSV’);
(I inserted this in a code element). However, it always returns an empty variable “csv”. I understand data are in the _trialsData dictionary. Is it necessary to “refresh” the psychoJS object somehow to get the _trialsData? Data are regularly downloaded at the end so I am pretty sure they are saved somewhere.
Thanks in advance for any help!
Mario
It looks like it is necessary to call
psychoJS.experiment.nextEntry();
before
let csv = psychoJS.experiment.getResultAsCsv();
I found this by trial and error… Can someone who is more expert tell if it is the right approach?
Thanks in advance,
Mario
Please could you confirm what you are trying to do and why?
I often use print statements (which auto translate to console.log) to send the values of individual variables or lists to the browser console for debugging purposes, but I can’t see why I’d want to send the entire data file.
My final goal is to save all the results on a local server. I am following
https://youtu.be/B4ZOX0t-kLM but in the process, for debugging purposes, I wanted to dump the csv to the console.
Could you, please, confirm that using
psychoJS.experiment.nextEntry();
is the right approach to get what is in the _currentTrialData dictionary?
Thanks!
Mario
I’ve just learned that thisExp.thisEntry contains a dictionary of the current row of data. I would imagine that psychoJS.experiment.thisEntry works online.
pschoJS.experiment.nextEntry() means move to the next row.
Yes. psychoJS.experiment.nextEntry only reports a single entry.
I tried calling
await psychoJS.experiment.save({
sync: true,
clear: false
});
but it downloads an empty csv file. It is as if another primitive should be invoked to “flush” the result but I am not able to find which primitive is
Anyone knows what is the right procedure?
Thanks again,
Mario
Have you tried the suggestion in my last message?
No, because I found, I was wrong from the very beginning for a different reason…
I put my original attempt
let csv = psychoJS.experiment.getResultAsCsv();
console.log(‘CSV_’+csv+‘_ENDCSV’);
in the wrong routine!
Now in the right place (close to the end of the experiment), it works fine.
Thanks for your support!
Mario