| Reference | Downloads | Github

Input () - EOFError: EOF when reading a line


I am trying to define the logging values. I want the user to enter with a name, before the experiment starts, but I’m getting an EOFError. What should I change in this code?

This is the first part of the code, just after the “imports”.

Thanks in advance

# Ask for the log file's name
LOGFILENAME = input ("Participant name:")

#Open a new file instance
log = open (LOGFILE + ".tsv", "w")

#Define a header
header = ["fixonset", "cueonset", "cueoffset", "taronset", "cueside", "tarside", "valid",  "soa", "target", \
    "response", "correct", "RT"]

#Transform header into strings and add line
line = map(str, header)
line = "\t".join (line)
line += "\n"

#Write the header to the log filename

The input() function doesn’t work with the PsychoPy Coder, as far as I know. You could use a psychopy.gui dialogue box.

from psychopy import core, gui

myDlg = gui.Dlg(title="My experiment")
myDlg.addField('logfile name:')
ok_data =  # show dialog and wait for OK or Cancel
if not myDlg.OK:  # quit if the user pressed cancel
LOGFILE = ok_data['logfile name:']

# here goes the rest of your code

Thanks Lukas!!

1 Like