Three values after dot in decimals when importing from excel

Hi all,

I am really struggling with getting right number of decimal places in PsychoPy builder (v2022.2.5). I have an excel stimulus file with decimal numbers. I need to present them in PsychoPy with three values after dot. For example, .95 should be presented as .950 I have tried import as a string or float, also tried round, but nothing works for me. In excel file I have saved decimals as numbers and set formatting, so the decimals have three values after dot. I also have tried to save decimals as text.

If anyone had a similar issue, could you please advice on solution.

Thanks a lot,



PsychoPy does not take the cell-format into account when importing values from an Excel-column. IN case you run the experiment offline, just define the text of your text-component as follows:

$format(stim, '.3f')

However, this will not work online. There is more work needed. Create a code-component that you set it to Both instead of Auto → JS and place it before the text-component. In the Begin experiment tab write on the Python-side

stimulus = 0

In the Begin routine tab write

stimulus = '%0.3f' %(stim) 

In the JS-side write

stimulus = 0;

in the Begin experiment tab and

stimulus = stim.toFixed(3);

in the Begin routine tab.

This code worked when run locally in a Firefox, Win10.

Refer with $stimulus in your text-component to the newly formatted number.

Best wishes Jens

Thanks a lot, this works fine. I am running offline experiment.


in case of an offline-experiment it makes sense to search the internet for the relevant python code and give it a try.

Best wishes Jens