Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Logging values of a dictionary variable for each iteration

edited April 2023 in OpenSesame

Hi,

In my Open Sesame experiment I have several dictionary variables defined inside a function such as the one below. I want to log all the values of these dictionaries per each iteration. I want to know if there is any possibility to log these data as custom variables? so that I can use the in-built Open Sesame logger function and do not have to write my own script. I am actually afraid to forget some important variables by writing my own logger. I would be thankful to hear any hint or idea.

dropped_element = {'Type': selection['Type'], 'X': x_drop, 'Y': y_drop, 'Time': selection['Time'], 'Index': selection['Index'], '_Removal_Delay': selection['_Removal_Delay']}

Many thanks,

PariShad

Comments

  • Hi PariShad,

    You could call it var.dropped_element and then the logger would automatically, save the entire dictionary. If you want each variable in that dictionary as separate column, you could do

    for key, value in dropped_element.items():
        var.set(key, value)
    

    Hope this helps,

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.