--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To post to this group, send email to psychop...@googlegroups.com.
To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/psychopy-users?hl=en.
Yes, more info is useful, especially error tracebacks as you've used
here. The encoding line at the top of the script only declares what
characters can be used within the script file - it doesn't alter the
conversion of characters from other auxiliary files.
It looks to me like you're trying to include non-ascii characters, not
just as strings for your stimuli but as *names* for parameters. That
definitely won't work, because the names get converted into variable
names and python variable names can't include non-ascii. That is, the
top row of parameter names should not include non-ascii. A possible
workaround for this, if you really need unicode param names, is to set
But I've just tested and it looks like unicode isn't supported by either
the python or matplotlib importers for csv files. I'm sure I can hack
something around that issue, but it might take a little while.
WORKAROUND: Can you save your file as an xlsx file instead? e.g. using
openoffice? The importer for xlsx DOES suuport unicode.
Jon
On 14/06/2011 14:11, C.S. wrote:
> Hi Henrik,
>
> thank you for your answer. Sorry for being so unspecific. I supposed
> it was a general problem.
>
> I use the coder (but mostly code generated by the builder) and the
> file starts with # -*- coding: utf-8 -*-, so I thought it should be
> able to decode my external .csv file.
>
> I haven't used open() but the usual
> #set up handler to look after randomisation of trials etc
> trials_2=data.TrialHandler(nReps=1, method=u'random',
> extraInfo=expInfo,
> trialList=data.importTrialList(u'LDT W�rter.csv'))
> thisTrial_2=trials_2.trialList[0]
>
> and then later:
> words=visual.TextStim(win=win, ori=0,
> text=WortART,
> ...)
>
> Is it possible that there is a problem with the file coding itself?
> It doesn't work with neither ANSI nor Unicode nor UTF-8 coding of the
> file, but the error messages are different.
> E.g. with UTF-8 coding of the csv file it says:
> File "E:\Carolin\Dissertation\Exp. 2\Vortest\Teil2.py", line 60, in
> <module>
> exec(paramName+'=thisTrial_2.'+paramName)
> File "<string>", line 1
> WortART=thisTrial_2.WortART
> ^
> SyntaxError: invalid syntax
>
> Greetings,
> Carolin
>
--
Dr. Jonathan Peirce
Nottingham Visual Neuroscience
This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.
This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
OK, and I now have a fix (I think) for the csv files too, if you want to
apply a little hack to PsychoPy:
In psychopy/data.py, around line 620 you'll find something that says::
#if it looks like a list, convert it
if type(val)==numpy.string_ and val.startswith('[')
and val.endswith(']'):
exec('val=%s' %val)
replace those lines with::
#if it looks like a list, convert it
if type(val)==numpy.string_ and val.startswith('[')
and val.endswith(']'):
exec('val=%s' %unicode(val.decode('utf8')))
elif type(val)==numpy.string_:#if it looks like a
string read it as utf8
val=unicode(val.decode('utf-8'))
and you should be rocking!
Jon
On 16/06/2011 13:17, C.S. wrote:
> Hi Jon,
>
> I tried what you were suggesting, but now I get another error message:
>
> File "E:\Carolin\Dissertation\Exp. 2\PsychoPy\Dateien f�r Exp.
--