Can you convert, with the Stringformatter from
integer = 1000000
integer = 1234567
integer = 234567
to
1 000.000
1 234.567
234.567
?
Or do you have to do some dirty python?
Can you convert, with the Stringformatter from
integer = 1000000
integer = 1234567
integer = 234567
to
1 000.000
1 234.567
234.567
?
Or do you have to do some dirty python?
Hi @sigtill
I think you will find an answer here:
https://knowledge.safe.com/questions/37508/format-number-with-commas.html
The StringFormatter seems to be based on the C printf function (doc) which doesn't seem to have thousand separators as a format string. But you can use a StringReplacer:
Modify the replacement text as needed. Regex for copy/paste purposes:
(?<=\d)(?=(\d\d\d)+(?!\d))
with this one, couldn't you also use an expression evaluator to divide by a thousand and return the double? or am I missing something?
with this one, couldn't you also use an expression evaluator to divide by a thousand and return the double? or am I missing something?
The StringFormatter seems to be based on the C printf function (doc) which doesn't seem to have thousand separators as a format string. But you can use a StringReplacer:
Modify the replacement text as needed. Regex for copy/paste purposes:
(?<=\d)(?=(\d\d\d)+(?!\d))
had a tinker to combine your regex and mine (by which I mean the regex a plagerised) into this, which I think works for decimals, but not integers now! I think given a bit more time we can tweak this to work with both, need to fix the grouping at the end.
(?<=\d)(?=(\d{3})+\.{1}\d+$)
had a tinker to combine your regex and mine (by which I mean the regex a plagerised) into this, which I think works for decimals, but not integers now! I think given a bit more time we can tweak this to work with both, need to fix the grouping at the end.
(?<=\\d)(?=(\\d{3})+\\.{1}\\d+$)
The Python code I posted here works pretty well, even for this particular use case: https://knowledge.safe.com/questions/37508/format-number-with-commas.html
Feel free to turn it into a custom transformer and put it on the FME Hub, if you want.