psychopy.org | Reference | Downloads | Github

Type Error: cannot concatenate 'str' and 'NonType' objects - please help!

Hey!
I’m quite new to PsychoPy, and am using the Builder vires (no programming skills)
OS Win 7, PsychoPy v1.84.2 (Standard Standalone?? - Sorry, I don’t really know what that means…)

I want to play a series of audio files. The files are in a folder called audios. I made an xlsx-file with a column called kontextaudio and containing the names of the files (kontext01, kontext02, etc.)

In the properties window of the sound stimulus, I defined the sound to be:
$“audios/”+kontextaudio+$".wav"
Thus the relative path shoud be audio/kontext01.wav, then audio/kontext02.wav, etc.
(I’m attatching a picture of the experiment plus the properties window)

Is that the wrong way to do that?
I’m attatching the error message as well (sorry, somehow I cannot just copy the text…)


I guess the solution is simple but I have tried to change the way I defined the sound and nothing worked… Thank you so much for your help!

Raina

Hi Raina,

I think formatted strings are the way to go - presuming kontextaudio is a variable see below:

'audios/%s.wav' %kontextaudio

Hopefully that will work!

Oli

Thank you @Oli!
I am using the builder, and I am quite inexperienced with PsychoPy, so can you tell me how I can implement this in the builder?
Do I put
‘audios/%s.wav’
in the sound properties box??

And where do I define
%kontextaudio

Thank you!!

That’s right but you’d have a dollar sign:

$'audios/%s.wav' %kontextaudio

make sure to include the part to the right too. Kontextaudio is set from your conditions file. The other way to do this would be to have the full path to each file in your conditions file under that column - but that is a bit fiddly.

BW

Oli

Dear @Oli,
If I do that, I get:
ImportError: Conditions file grmJudg-Saetze.xlsx: Missing parameter name(s); empty cell(s) in the first row?
But my .xlsx-file looks like this:

Is there any error in that?

Hi Reina,

I have a feeling it might be the non-unicode characters in column B - could you upload your conditions file so I can check?

Many thanks,

Oli

EDIT

I’ve just tried some Czech words with similar symbols and there was no problem. Other issues could be the format (it has to be XLSX, CSV or PKL - so so not XLS or ODS) - or that you have a space hidden in one of the cells - OR you may have a duplicate variable name - there should be no other element in your experiment called kontaxt or kontaxtaudio…

Dear @Oli,
Thanks for your support!
I checked all the things you mention, but all of them seem to be according to the rules… Still, I keep getting the message about “missing Parameter name(s): empty cell(s) in the first row?”
I’m uploading the xlsx-document here (I changed the names of the file and variables, and went back to just typing the whole path in the excel)
file.xlsx (9.3 KB)
What could be wrong about the variable cells?
Thanks!!

I have no idea what’s caused that - it might have been some strange formatting issue (you column headers were in bold) - I copied and pasted the values into another excel sheet and now it imports fine. The original now says that there are 13 conditions with two parameters - I’ve uploaded both in case any one wants to look deeper into this but file2.xlsx is the one you want… also - if you want to use the string formatting as mentioned above, it should work properly now too.
Best wishes,
Oli
file2.xlsx (24.1 KB)
file.xlsx (9.3 KB)

1 Like

Thank you, @Oli! Now it workes! So strange, I had already changes the xlsx-files before and it had not helped, but now that works fine! :slight_smile: Thank you for your help!

Great! Please could you set the thread to solved? Good luck with your data collection.

BW

Oli