| Reference | Downloads | Github

SaveAsExcel problem


Hi, I´m a new psychopy user. I have problems saving the outputs of my experiment using “SaveAsExcel”.

I used this tutorial to make my code: (my code is quite similar).

When I do a print of my outputs I see all of them but in the .xlsx file I see only the last trial output.

My question is: Maybe I was overwritting the file?


Ps: Sorry for my bad english.


It is indeed probable that you are overwriting the file, and your English was great! But if you need a more a specific answer than that you’ll have to be more specific about what you did, as in include a code example (put three backticks (```) on the line before and the line after to format the code correctly). Also keep the example short but complete.


Thank you @daniel.riggs1 .

I do this:

respuestas = [] #Creo una lista que contendra las respuestas

trials = data.TrialHandler(respuestas, 1, extraInfo= {'participant':"1", 'session':1})'Respuesta y tiempo')  # add as many types as you like'Rating')'Tiempo en decidir el rating')  # add as many types as you like

Then I do a loop (showing images, asking for “yes or no” and a rating scale)

Finally I try to save the outputs that look quite similar to this:

[(‘left’, 0.32137296348810196)]
(29, 1.741)
[(‘right’, 1.4981680205091834)]
(79, 1.053)

    print(rating,decisionTime) #Inside of the loop
    respuestas.append({'Rating' : rating}) #Inside of the loop
    respuestas.append({'Tiempo en decidir el rating' : decisionTime}) #Inside of the loop

# outside of the loop
while True:  
        thisTrial =
    except StopIteration:  # we got a StopIteration error
        break  # break out of the forever loop'"Si o no" y tiempo', keys_and_time)"Tiempo en decidir el rating", decisionTime)  # add the data to our set'Rating', rating)

# Luego del experimento

                   dataOut=['all_raw'], appendFile=True)

I hope you understand what I did here.

Thank you again.


Hi Gustavo, please edit the post and put the three backticks on the line above and the line below your code because it’s very difficult to read otherwise:


for i in range(0,2):
    print(u"Así se queda bonito")


Y tu inglés es fantástico


Done! Haha thanks for the compliment!


Done use saveAsExcel(). It tries to summarise the data rather than output the raw data per trial, which might be why you are only seeing one line in the file.

Use saveAsWideText() instead.


Thanks @Michael . I Try to use SaveAsWideText() but I get the following message: "AttributeError: ‘module’ object has no attribute ‘endswith’ "

edit: I solve the problem wth “endwith” but I got the same Output that got in the beggining. The FILE only have the last trial.


I’m a bit confused by your code. You feed an empty list to the TrialHandler when creating it. I think it really needs a trialList there that would correspond to the number of trials you intend running. So it might not be surprising that there isn’t much content in the TrialHandler. i.e. appending items to the trialList object won’t do anything after the TrialHandler itself has been created.

But we can’t really see the full structure of what you are doing, or why you would try to add data to the TrialHandler ‘outside of the loop’ (which I’m assuming means after the trials have been run.

Have you looked at the TrialHandler demos to see you this class is used?