Disable scientific notation in output

How can I disable all scientific notation in my outputs?

Currently my outputs look like

Gisborne Region            9.99500166624978E-4     6.821410620121793E8
Gisborne Region            0.001998001332666921    5.755217549897512E8
Gisborne Region            0.00498752080731768     4.1450825341889817E8
Gisborne Region            0.009950166250831893    2.9385194781682825E8
Gisborne Region            0.019801326693244747    1.9400402302882728E8
Gisborne Region            0.048770575499285984    8.507156773087195E7
Gisborne Region            0.09516258196404048     4.569967654252194E7

Hi John,

I don’t think there is a way to turn off scientific notation currently in RiskScape.

The simplest approach for large numbers (i.e. your 3rd column) is to convert it to an integer rather than a floating point number. You can use round() to do this, or int() (which will implicitly round).

For very small numbers (e.g. your 2nd column), or cases where the precision of large numbers is important, you could add a simple Python function to convert the floating-point number to a text string in the format you prefer before you save the data. E.g.

def function(x):
    return f'{x:.20f}'.rstrip('0').rstrip('.')

With an INI defintion like:

[function no_scientific_notation]
location = no_sci_notation.py
argument-types = [ floating ]
return-type = text

Note be careful to only do this immediately before you save the data to CSV. Some operations (e.g. sum()) may behave quite differently when you give them text strings.

Cheers,
Tim

1 Like