Skip to main content
Question

Converting a String to a Number

  • November 15, 2012
  • 6 replies
  • 3980 views

How can I convert a string to a number so I can perform arithmetic calculations?
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • 3719 replies
  • November 15, 2012
HI,

 

 

If you have a digit, it should not be an issue, otherwise have a look at the StringFormatter.

 

 


davideagle
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 578 replies
  • November 15, 2012
The StringFormatter is the way to go as Itay suggests...

 

 

You can also consider the @Evaluate function to allow string based transformers to consider the value as a number, like:

 

 

@Evaluate(<STRING>)

fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • 3719 replies
  • November 16, 2012
Yes, in general FME will just automatically convert any string to a number when it needs to. You can do this with the new String Editors that are part of any parameter (click on the down-arrow to the right, and you'll see the string/math editors there) -- there are always "math functions" there and you can just refer to attributes inside of the math functions -- for example @double(@Value(myAttr)) -- all possibly by drag and drop.

david_r
Celebrity
  • 8394 replies
  • November 19, 2012
When handling floating point numbers with international source data, there can arise a situation where FME is unable to convert a string to a number if the decimal delimiter in your input data differs from the one defined on your system. Notably, the decimal delimiter is "," (comma) in some regions and "." (point) in others.

 

 

To resolve such problems, use a StringReplacer to set the correct decimal delimiter before doing arithmetic operations, that will usually take care of it.

 

 

David

robd
Contributor
Forum|alt.badge.img+2
  • Contributor
  • 6 replies
  • September 9, 2014
If StringFormatter doesnt work with integers an alternative is to use an AttributeRounder before ExpressionEvaluator round to 1 or 2 dp, then round back to 0 after the ExpressionEvaluator.

akunyer
Participant
Forum|alt.badge.img+1
  • Participant
  • 1 reply
  • January 8, 2019
Yes, in general FME will just automatically convert any string to a number when it needs to. You can do this with the new String Editors that are part of any parameter (click on the down-arrow to the right, and you'll see the string/math editors there) -- there are always "math functions" there and you can just refer to attributes inside of the math functions -- for example @double(@Value(myAttr)) -- all possibly by drag and drop.

it works !!! thanks