Number formatting in Reports (Ignition 8.1.2)

If you're in Perspective and dealing with a single number to string operation at a time, you can lean on Java's tools to do it simpler and faster:

from java.text import NumberFormat
from java.util import Locale

nf = NumberFormat.getCurrencyInstance(Locale.GERMANY)

print nf.format(123.45)
print nf.format(51106.01)
>>> 
123,45 €
51.106,01 €

You can wrap that up in a project library script to save the cost of importing and I can guarantee it'll be much faster than the repetitive string replacement operations (not that it's really going to matter in this case) - but I would argue it's much, much nicer to read.

2 Likes