Jan-06-2019, 09:17 PM
(Jan-06-2019, 02:50 AM)scidam Wrote: I just installedpsychopy
with lots of its dependencies...
Everything works fine until line 30.
If you looked atstartInfo
, you could find that it is just a list of strings.
So, thedataFile
variable is a string too. Attempting to call nonexistent.write
method (line #32) for the string
rises the error. I got the following:
If you want to write data into a csv file, I would suggest you to use the
Error:Traceback (most recent call last): File "test.py", line 32, in <module> dataFile.write(",".join(dataHeader) + "\n") AttributeError: 'str' object has no attribute 'write'Pandas
package,
data frames and magic method.to_csv
. Using Pandas wouldn't be an overkill, if we take into
account tons of dependencies of the pychopy package:)
Alternative way is to create file and write to it directly, e.g. insert the
following piece of code instead of lines #30-33:
dataHeader=["Participant","Age","Gender","Handedness","Trial","Cue Side", "SOA","Target Type","RT"] with open("mydata.csv", "w") as dataFile: dataFile.write(",".join(dataHeader) + "\n")Note that I've never usedpsychopy
before. So, it might also include
its own mechanism of storing data to files and we don't need to build such things from scratch.
Thanks, this was very helpful!