| Reference | Downloads | Github

Saving Data with TrialHandler-ValueError

Data saves when running through Psychopy Coder (in both a log and the downstream csv), but when running my scripts through the Terminal with pythonw, I get the error below.

  File "", line 90, in <module>
  File "", line 83, in fulltask
  File "/Users/utooley/Dropbox (Personal)/psychopy/netlearn_kids_v1/", line 167, in do_runtrials
    trials.saveAsText(fileName=logname, delim=',', dataOut=('all_raw'), appendFile=False)
  File "/Users/utooley/anaconda/lib/python2.7/site-packages/psychopy/data/", line 206, in saveAsText
  File "/Users/utooley/anaconda/lib/python2.7/site-packages/psychopy/data/", line 401, in _createOutputArray
    dataOut, dataAnal, dataHead = self._createOutputArrayData(dataOut)
  File "/Users/utooley/anaconda/lib/python2.7/site-packages/psychopy/data/", line 489, in _createOutputArrayData
    dataType, analType = thisDataOut.rsplit('_', 1)
ValueError: need more than 1 value to unpack 

The relevant code:

tidx = 0

    for tidx, trial in enumerate(trials):
        #do some stuff

        logging.log(level=logging.INFO, msg="Trial %i - Stimuli1 %s - Stimuli2 %s" % (tidx+1, trial['path1'], trial['path2']))

        #Set values for trial
        onset = globalClock.getTime()'onset', onset)

        #while not mouseclick.getPressed():
        #while globalClock.getTime() < (tidx+1)*trialDur:

        while not Pressed:


            if sum(mouseclick)>0:
                Pressed= True

logging.log(level=logging.INFO, msg="*** END ****")
trials.saveAsText(fileName=logname, delim=',', dataOut=('all_raw'), appendFile=False)

Any thoughts on the issue? I just updated standalone psychopy to 1.90.2, but I believe when I run from the terminal I’m using Psychopy installed using pip, I get PsychoPy 1.85.6 <pip> in my list of environment packages. I’m on OS X 10.11.6.

Update: after updating to standalone 1.90.2, I now get the same error when running from the Coder.

Since the error doesn’t occur when using the standalone, I guess it’s possible the problem is something to do with the version of one of the dependencies installed in your own Python.

In the first instance, I’d simply suggest you use saveAsWideText() in place of the old saveAsText(). It should give a more standard data output structure, and it doesn’t (I think) call the _createOutputArrayData() function where your error seems to arise.

1 Like

Thanks so much! That fixed it, works perfectly! Both when running from the command line and from within Coder.

As an update, I also started getting the error when running from Coder after updating to 1.90.2 instead of 1.85, so it seems plausible that it’s something under the hood with dependencies.