Python for psychopy

Hello all
I’m having difficulty saving time with my experiment coded in Python and using Psychopy.
I created a clock:

self.imagetimer = core.Clock()

Each time a new image is presented I get the time

self.whattime = self.imagetimer.getTime()
print(self.whattime)

I can see it on the runner; but I’m failing saving it as a csv:
np.savetxt(self.timename + ‘.csv’, np.c_[self. whattime], fmt=‘%f’, delimiter=“,”)

It create the file, but only contains the last value.

I tried adding an append
but then it gets stuck

Do you know what I’m missing?
Thanks!

image

Dear Lysiane,

It may be better to ask this question in the psychopy forums: https://discourse.psychopy.org/

Also as for your question, if not absolutely necessary I’d suggest you to use Pandas or Python’s native file writing IO instead of numpy. Also, I noticed that the function you are calling is called savetxt, but the file you are trying to save is a “.csv” file. Maybe that is the reason your file is not being saved properly.

All the best