psychopy.org | Reference | Downloads | Github

Recovering data help

Hi,

I’ve just noticed that one of my data files (the excel .cvs file) is empty. I must have accidentally overwritten in after opening it (the other participants’ files are fine). I do still have the log file and the psydat file (don’t normally use these as I create a pivot table in the excel file for analysis).

Is there any way I can recover the excel file from the other data file (log and psydat) files?

Many thanks

Hi @MariaBristol, you should be able to retrieve your data from the psydat file. Please see this link for guidance.

Thanks very much, I’m trying this right now.
I don’t usually code in Python. presumably I have to change the file name and pathways in the piece of code in the link you gave me.
For example, what does “psychopy.misc” refer to in that code? Is it a pathway?

When I use the code in the link I get an error message saying there is no module called psychopy.misc

Thanks for your help.

Full error message:

Traceback (most recent call last):
File “<pyshell#0>”, line 1, in
from psychopy.misc import fromFile
ImportError: No module named psychopy.misc

Ok, are you using standalone psychopy?

Hi, I’m running an older version of Psychopy on a Dell laptop

“Welcome to PsychoPy2!
v1.82.01”

The experiment has been running a long time and I didn’t want to change versions throughout.

(I hope this answers your question).

Ok thats fine. I think the problem is that you are running from PyShell, which will not have access to the standalone PsychoPy modules. Would you please try the code in PsychoPy’s Coder, and let me know?

Thanks again.
I tried running the code in Psychopy’s coder view.

I kept the code the same, except I changed the name of the data file I’m trying to reover (7Test.psydat).
Below is the code I used, but when I ran it nothing happened (was it supposed to create an output file?). There were also no error messages.

Code I used:

from psychopy.misc import fromFile
datFile = fromFile(‘7Test.psydat’)
#get info (added when the handler was created)
print datFile.extraInfo
#get data
print datFile.data
#get list of conditions
conditions = datFile.trialList
for condN, condition in enumerate(conditions):
print condition, datFile.data[‘response’][condN], numpy.mean(datFile.data[‘response’][condN])

Great that it seems to work. Have you go the “output” tab selected, so you can see the output? Also, you will need to change the code. First, just try printing the following, which should be output to your “output” tab at the bottom of the Coder view:

from psychopy.misc import fromFile
datFile = fromFile(‘7Test.psydat’)
#get info (added when the handler was created)
print datFile.extraInfo
#get data column names
print datFile.dataNames

Hi, when I print that code nothing appears in my Output tab

Apologies, this is what I get:

Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.82.01-py2.7.egg\psychopy\app\coder\coder.py”, line 2045, in runFile
fullPath = self.currentDoc.filename
AttributeError: ‘NoneType’ object has no attribute ‘filename’
Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.82.01-py2.7.egg\psychopy\app\coder\coder.py”, line 2045, in runFile
fullPath = self.currentDoc.filename
AttributeError: ‘NoneType’ object has no attribute ‘filename’

Sorry, not sure what is going on here. Is the psydat file in the same directory as the script? Also, please replace the quotes in the copied code, as sometimes that can create a syntax error when you copy and paste them.

Okay, I’ve tried again (double checking the directory and the quotes). To be clear I paste that code into the “Shell” tab of the coder view, and then I get the following error message in the “output” tab:

########## Running: C:\Experiment 9 Pilot Data Collection\untitled.py ##########
Unexpected error loading library avbin:
Unexpected error loading library avbin:
2.2278 ERROR avbin.dll failed to load.
Try importing psychopy.visual as the first library
(before anything that uses scipy)
and make sure that avbin is installed.
2.3047 ERROR avbin.dll failed to load.
Try importing psychopy.visual as the first library
(before anything that uses scipy)
and make sure that avbin is installed.

Ok. Don’t worry about the avbin error unless you are using movies. Instead of using the shell, create a script and run it from Coder. Try this one attached and check the output.

openPsydat.py (400 Bytes)

Thanks, this is what I get now:

Welcome to PsychoPy2!
v1.82.01

######### Running: C:\Experiment 9 Pilot Data Collection\openPsydat.py #########
Your current working directory : C:\Experiment 9 Pilot Data Collection
Exception AttributeError: “‘ExperimentHandler’ object has no attribute ‘dataFileName’” in <bound method ExperimentHandler.del of <psychopy.data.ExperimentHandler object at 0x02FF0B10>> ignored
Traceback (most recent call last):
File “C:\Experiment 9 Pilot Data Collection\openPsydat.py”, line 7, in
datFile = fromFile(‘7Test.psydat’)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.82.01-py2.7.egg\psychopy\tools\filetools.py”, line 34, in fromFile
contents = cPickle.load(f)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\numpy\ma\core.py”, line 5550, in setstate
ndarray.setstate(self, (shp, typ, isf, raw))
TypeError: object pickle not returning list

I think you may be better off upgrading your standalone version of PsychoPy because I believe these issues have already been addressed by upgrading libraries, such as numpy. You can always downgrade for testing.

That sounds sensible. Thanks very much for all your help.

No problem, please let us know if you have any further issues.