URL of experiment: https://pavlovia.org/petab/tokendebug
Description of the problem:
so I was wondering if anyone needed to load and write files during experiment. I’ve seen quite a recent post with similar topic, here - https://discourse.psychopy.org/t/experiment-not-saving-data-online-generates-empty-csv-files/8174
My goal is to use a csv file as a counter and everytime the experiment runs, the number in csv increases by 1. The file is then saved and overwriten with next run, so it contains always the last saved number.
Here is some idea with python script:
So this would be in begin experiment tab:
counterW = 0
and for the begin routine:
counterW = counter ## load content of the file into new variable counterW = counterW + 1 ## increasing by 1 import csv with open('counter.csv', 'w') as csvfile: writerC=csv.writer(csvfile, lineterminator='\n') writerC.writerow(['counter']) ## write row with header 'counter' writerC.writerow([counterW]) ## add increased number to second row
The file is loaded in the loop and I’m accessing its content by simply using ‘counter’ variable used as a header in the file.
I’m already quite skeptical about that, but it would be great to have a solution to it.
Btw. the experiment is just for this fix, it’s not working and does not have any content.
Thank you very much!