| Reference | Downloads | Github

CSV not Saving on exit

Hi all,

Really liking the new discourse forum, brings an up to date feel!

This is probably an issue with my installs but for some reason I cannot get data to save as I normally would.

I got really into coding using Sublime Text recently as I like the markdown and feel of it and managed to get a REPL working on my default Python path but I had some issues as over the years I have tried several python IDEs and distributions (like enthought, psychopy standalone, pizo etc) to make it easy to get into the coding without the need to know hoe packages were installed, what a path was etc. I decided to have a clean up and get down to one distribution and started again.

Using your manual install methods using pip on my shiny new installation I set about getting all the dependencies. more or less everything installed fine with the exception of scipy, lxml, tables where I had to manually download and install.

I can now run Psychopy stuff in sublime and it displays stuff fine but there is two issues:

Firstly, using the psychopy coder, when an experiment ended it would automatically close the window whereas I believe now I need to use win.close() which is fine.

The second is is that on exit my latest script doesn’t seem to save a CSV at the end. Here is some relevant bits to my code:

personalImList = [ {‘image’: os.path.join(personalFolder, x)} for x in personalImages ] # to create a list of dictionaries of image names

EP_Exp = data.ExperimentHandler(
name=‘EP Physiology Image Task’, version=‘1’,
extraInfo = info,
dataFileName = filename

trials = data.TrialHandler(trialList = personalImList, method = ‘sequential’, nReps = 1)


for thisTrial in trials:

rt = None

print "image chosen = ", thisTrial['image']

for frameN in range(300): #probably the bit with the serial trigger here in future

win.flip() # Clear screen


keys = event.waitKeys(keyList = ['z', 'm'])

resp = keys[0]
print resp
print rt
print 'Saving Data....'
trials.addData('image', thisTrial['image'])
trials.addData('DecTime', rt)

if resp == 'z':
	trials.addData('ChosenAnswer', 'Man Made')
	print 'Answered Man Made'
elif resp == 'm':
	trials.addData('ChosenAnswer', 'Natural')
	print 'Answered Natural'


trials.finished = True


This might be to do with some dependency maybe that is required to save to CSV at the end but i do not receive any errors about package problems…

EDIT: im using Windows

EDIT 2.0: ok this is really odd, on my last try there was still no files in my data folder but i went back about 5 mins later and now i have loads of csv files and psydats. is this some sort of buffer problem in python based on the way i have quit the sessions?

Ok I discovered the issue and I was right in that its not psychopy but in fact the REPL was not exiting the routine despite the core.quit() call.

To sort this you need to type into the interpreter quit() and the datafile will appear. In sublime (using sublime REPL) when you simply quit the tab this will not work as it doesn’t properly close the session. Hope this helps folks in the future.

1 Like