Convert psydat to csv file / cannot open a psydat file

Hi all. My experiment was created with Builder 3.2.2, running on macOS Mojave 10.14.4. I’m very new to coding in Python, please bear with me. For one full experiment, only one csv file was created out of 12 participants : for the other participants, a psydat file was issued for each. I tried loading the psydat files with psychopy.misc.fromFile in the coder view and in Terminal running in Python, but I get the “No such file or directory” error. What am I doing wrong?
Thanks a lot for your help.

Running: /Users/p43547/Applications/

psydat: /Users/p43547/Applications/
Traceback (most recent call last):
File “/Users/p43547/Applications/”, line 20, in
exp = fromFile(file_psydat)
File “/Users/p43547/Applications/”, line 54, in fromFile
with open(filename, ‘rb’) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘/Users/p43547/Applications/’

Hi again! I was not able to recover the file, even if I wrote the good path and even when following this script : Data outputs — PsychoPy v2021.2.4. I will be grateful for any help! Thanks.

Hi There,

Have you tried the “csvFromPsyDat” demo in the coder of the newest release (2021.2.3)?


Hi Becca,
I tried it with the following script and it worked! Still don’t know what I was doing wrong earlier. Thanks a lot for your help.

"""utility for creating a .csv file from a .psydat file

edit the file name, then run the script
from __future__ import print_function

import os
from import fromFile

# EDIT THE NEXT LINE to be your .psydat file, with the correct path:
name = '/Users/p47/Desktop/nameofthefile.psydat'

file_psydat = os.path.abspath(name)
print("psydat: {0}".format(file_psydat))

# read in the experiment session from the psydat file:
exp = fromFile(file_psydat)

# write out the data in .csv format (comma-separated tabular text):
if file_psydat.endswith('.psydat'):
    file_csv = file_psydat[:-7]
    file_csv = file_psydat
file_csv += '.csv'

print('-> csv: {0}'.format(os.path.abspath(file_csv)))```

Hi Rosalie,

Splendid!! if this answered your question please do mark the response that solved the problem with “solution” so that future users know!


1 Like