Question

decimal #s with trailing zeros compared with same #s without trailing zeros

  • 31 January 2017
  • 5 replies
  • 15 views

Badge

Hi there, I'm using the UpdateDetector transformer and it's detecting changes with lat/long fields where numerically there's no difference. This is because in one reader (the CVS reader) these two fields have trailing zeros, while in the other reader (an oracle table) they do not. What's the best way to resolve this?


5 replies

Badge
Make that CSV reader (not CVS reader):)

 

 

Userlevel 2
Badge +17

Hi @ieukcoca, you can cast the internal data type of the attributes from character string to floating point number using the @double function in the ExpressionEvaluator, and then compare it with the value from the Oracle dataset.

Badge +16

Hi @ieukcoca,

Alternatively you can try the StringFormatter to truncate the CSV values (.2f for 2 decimals) before the comparison.

Hope this helps.

Userlevel 2
Badge +12

Another way of doing this would be to create a point geometry from both source lat/long attributes (Setting the CSV attribute types to X-coordinate and Y-coordinate or using the VertexCreator transformer).

The geometry should be the same as both sources will be interpreted as numeric fields.

Badge +7

One suggestion that could be to use a StringReplacer on the data that has trailing zeroes. Use a Regular Expression Replace and use the Regex "(0+)$" without the quotes. Leave the replacement text field blank and it will drop the trailing zeroes.

 

Another would be to use an AttributeRounder transformer on both sets of data and conform them all to a specific number of digits.

Reply