Loop from file
in OpenSesame
Hi there!
I can't seem to generate my loop table from a UTF-8 csv file. When I attempt to quick-run or preview the table, I get the following error message:
Failed to read text file: /var/folders/87/7y86f4p93bg484clz6jnny3w0000gn/T/tmpirWFfJ.opensesame_pool/food_trials.csv
item-stack: experiment[run].practice_loop[run].block_sequence[run].block_loop[run]
exception message: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?
time: Fri Nov 4 14:23:10 2016
exception type: Error
Traceback:
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/loop.py", line 202, in _create_live_datamatrix
src_dm = io.readtxt(src)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/python_datamatrix-0.3.0-py2.7.egg/datamatrix/io/_text.py", line 50, in readtxt
for column in next(reader):
Error: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?
I'm also attaching my csv here.
Thanks!
-Jonathan

Comments
Hi everyone,
I'm still not able to read from this file, but the error message has changed:
Failed to read text file: /var/folders/87/7y86f4p93bg484clz6jnny3w0000gn/T/tmpBnfMsG.opensesame_pool/food_trials.csv
item-stack:
exception message:
time: Sun Nov 6 20:29:29 2016
exception type: StopIteration
Traceback:
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/loop.py", line 202, in _create_live_datamatrix
src_dm = io.readtxt(src)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/python_datamatrix-0.3.0-py2.7.egg/datamatrix/io/_text.py", line 50, in readtxt
for column in next(reader):
StopIteration
Has anyone had problems like the above when trying to loop from a csv file in OSX? Any insights?
Thanks!
-Jonathan
Hmmm... so I just re-saved my excel spreadsheet as a .csv (UTF-8) and it not works with the new file. Not sure what I changed
Sorry for the distraction!
Ahhhhhh I tried a new .csv (attached) and it went back to the same error message (I think -- I can't tell if this message is meaningfully different from the first one above). I know from the manual that csv's should be
I think I've satisfied all of the above, but the error seems to have something to with the double-quoted requirement? The only newlines that occur in my .csv are for new rows. Nothing fancy (I think) between commas.
Here's the error message:
Failed to read text file: /var/folders/87/7y86f4p93bg484clz6jnny3w0000gn/T/tmpBnfMsG.opensesame_pool/factorial_food.csv
item-stack:
exception message: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?
time: Sun Nov 6 21:23:36 2016
exception type: Error
Traceback:
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/loop.py", line 202, in _create_live_datamatrix
src_dm = io.readtxt(src)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/python_datamatrix-0.3.0-py2.7.egg/datamatrix/io/_text.py", line 50, in readtxt
for column in next(reader):
Error: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?
Hi,
This is due to the line endings. Mac OS, Windows, and Linux use different characters to indicate the end of a line, and datamatrix cannot deal with the Mac OS end-of-line characters. I'll file a bug report on this. For now, you can simply do what you already did:
.xlsxfile instead; or.csvto Unix-style (how exactly depends on your text editor).Cheers and thanks for pointing this out!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks so much, Sebastiaan!
Sorry, I should have mentioned this earlier, but I was persisting with the .csv because I had tried to use an .xlsx file and got the same error as this user, but when I entered the code you provided into the debug window and hit enter, it didn't seem to have any effect. I now think this was because I pasted both lines:
and hit enter. When I entered just line 1 and hit enter, then just line 2 and hit enter, it worked! Probably something I should have known, but as I'm sure you can tell I'm a bit of a programming noob!
Thanks again,
-Jonathan