FME change data format from string to numeric

695 Views Asked by At

Struggling with a really simple problem; I need to convert attribute from string to numeric in FME. have tried using the arithmetic editor, but every time I export to GIS I get string. It seems when one uses the statistics calculator you get numeric. Any ideas? As I am all out of them. Ashton

1

There are 1 best solutions below

0
Helmoet de Zwijger On

One could start using an AttributeCreator to create:

  • new attribute: _result
  • attribute value: @ReplaceRegEx(@Value(_orig_value),[^\d.-+],,FALSE)

The AttributeCreator will get whatever is in the attribute _orig_value, removes everything that is a not digit, dot or sign and tries to convert the value into a float value in the new attribute _result.

When writing stringvalues to a float database field, FME will convert the string automatically to float.

Note: Be careful to use regex to recognize numbers like this, it could end up combining all digits from multiple number values in one string, into one large number value, or result in 'numbers' having multiple decimal separators. To tailor the way numbers are recognized, adjust the regex [^\d.-+] above.