Read file name from excel to get specific element character info

OS (e.g. Mac 11.0.1):
PsychoPy version (PsychoPy3):
What are you trying to achieve?:
I need to read the characters from the image filename of the list in excel. For instance, for a randomly selected picture AM01S.JPG I need to read if image[1] == “M” for Male to display Male text names below the displayed picture. Then, based off what they select, I need to do something like “left arrow selects a random picture where image[4] == “S””. This also goes into being able to select one image in excel, with replacement, after each selection.

What did you try to make it work?:
I tried printing the excel picture name into a string variable to read but I can’t seem to get the Code to communicate with the name of the image.

I’m willing to hear other approaches even if it includes not using excel to import the images.
Thank you.