Skip to main content
Good day,

 

 

I am having a problem and hoping that the experts (ok, heroes) would be able to help me.  I have an ArcGIS gdb file geodatabase containing hundreds of polygon shapefiles.  Each of these shapefiles has a bunch of attribute fields, and 13 of the fields have a data type of "text" by default but should have been numeric.  Would someone please show me step by step of how to use FME to convert these fields into a numeric data type so that I can use them to perform calculations?  I need to do this for all of the shapefiles in this geodatabase, and there are hundreds of them as mentioned.  How do I save time without having to set up the schema mapping for each of these shapefiles?

 

 

Thanks,

 

 

Johnson
Hi,

 

 

Depending on your desired numeric output, you can configure the StringFormatter transformer.

 

Hope this helps.
Hi,

 

 

as long as the text strings contains a valid number (according to your operating system locale settings), FME should be able to do calculations on them regardless of their input data type, without needing to be converted first.

 

 

It is, however, quite common to find floating point numbers where the decimal point doesn't correspond with your locale settings, e.g. "1,23" vs "1.23", which can prevent FME from converting them to floats for calculation. If that is the case, you can use a StringReplacer to replace the comma with a point, or vice-versa, before doing the calculations.

 

 

If you have attributes that contain a mix of numbers and text, consider using the AttributeClassifier to filter out valid numbers.

 

 

David
Hi Johnson,

 

 

in addition, note FME assumes a digit string without a decimal point is an integer value in the numeric calculation. Since the division process of two integer values generates an integer value (e.g. 3 / 2 = 1), when you need to get real value (3 / 2 = 1.5), consider using the '@double' function in the expression or using the StringFormatter to change the string to a finite decimal representation before calculating.

 

 

Takashi
`StringFormatter_formatter' -- expected floating-point number but got " "

 

 

The string perhaps is one or more white space(s).
Takashi is right, the NullAttributeRemover won't touch strings that contain spaces.

 

 

Use an AttributeClassifier before the StringFormatter.

 

 

David
Hi Johnson,

 

 

did you find out the error reason? If the error reason was spaces, using the AttributeTrimmer transformer might be a solution. The parameter settings of the AttributeTrimmer are:

 

Trim Type: Both Trim Characters: <not set> Allow Trim Down to Nothing: Yes

 

Takashi
Good day all,

 

 

It worked!  Using the AttributeTrimmer as Takashi has suggested must have removed all the white spaces in those 13 attribute fields within my reader dataset, thus allowing me to rewrite it into a new database with those fields re-designated as double via the user attribute tab in the writer dataset.  Thank you very much for the assistance!

Reply