Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

IOError: [Errno 2] No such file or directory: '{my_file_name}.csv'


First, I'd like to thank the makers of this amazing software. I can't believe something this great is also free!

I'm having an issue accessing my csv through OpenSesame. I have some randomly generated numbers coded with inline script and stored to the csv with a logger.

I want to be able to access the .csv with inline scripting. So far, I feel like my code is working, but I don't know how to tell it where to search. Here's an example of my code:**

import csv
csvname = "subject-" + str(var.subject_nr) + ".csv"
with open(csvname) as csvfile:
data = csv.reader(csvfile, delimiter=',', quotechar='"')

I get this in the debug window:

Error while executing inline script

item-stack: experiment[prepare].calculate_payment[prepare]
exception type: IOError
exception message: [Errno 2] No such file or directory: 'subject-0.csv'
item: calculate_payment
phase: prepare

File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 81, in prepare
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 161, in _exec
exec(bytecode, self._globals)
File "", line 5, in
IOError: [Errno 2] No such file or directory: 'subject-0.csv'

Is there something I'm doing wrong? I'd like for it to read the csv file from the same directory as where my experiment is saved. THANK YOU!


Sign In or Register to comment.