Best way to open psydat file?

Hello everybody,

I need some information from the psydat file which are not available in the csv- or excel-file. I was wondering if there is a way to open the psydat-file which shows the information properly in columns or something similar (not in a huge text file like in the Windows editor)?

Kind regards,
Annie

PS: I tried to convert the psydat file in an Excel file and in a csv-file but then I can’t see the information I need but I know from the txt-version of the psydat-file that the information I need are (somewhere) in there.

1 Like

Hi @Anni,

One way would be to try to extract the data following the documentation for psydat files: http://www.psychopy.org/general/dataOutputs.html

You could use something like:

from psychopy.misc import fromFile
import numpy as np
dirs = "C:\\path_to_psydat_file\\"
datFile = fromFile(dirs+'subj1.psydat')

# datFile has experiment handler information
print(dir(datFile))
# for trialHandler data
trialHandler = datFile.loops[0]
# see list of trialHandler parameters
trialHandlerParams = dir(datFile.loops[0])
print(trialHandlerParams)
# View data
print(trialHandler.data)
print(trialHandler.data['ran'])
print(trialHandler.data['order'])
print(trialHandler.data['key_resp_2.rt'])

# Save variables of interest to a csv file...
np.savetxt('newFile.csv', np.array(trialHandler.data['key_resp_2.rt']), delimiter=',', newline='\n')
2 Likes