Skip to main content
Archived

Python API: new setAttributeType() method for FMEFeature class

  • August 10, 2017
  • 1 reply
  • 31 views
vlroyrenn
siennaatsafe
david_r
redgeographics
danilo_fme
+13
  • vlroyrenn
    vlroyrenn
  • siennaatsafe
    siennaatsafe
  • david_r
    david_r
  • redgeographics
    redgeographics
  • danilo_fme
    danilo_fme
  • warrendev
    warrendev
  • tcrossman
    tcrossman
  • bruceharold
    bruceharold
  • lorenrouth
    lorenrouth
  • jelle
    jelle
  • geosander
    geosander
  • afleming26
  • nicohauri
    nicohauri
  • xabi
    xabi
  • jneujens
    jneujens
  • janb
  • lopeztor
  • kmh3bd

geosander

There already is a getAttributeType() method on the FMEFeature class, but it would also be nice to be able to set (=convert!) it, if this is feasible. This is useful if we want to enforce/maintain a certain character encoding (as discussed here), or if we want to convert an integer to a boolean, a numeric string to a real etc. etc.

The method could look like this:

setAttributeType(attrName, attrType, [attrEncoding])

Sets/converts an attribute into another type. Attribute type must be one of FME_ATTR_UNDEFINEDFME_ATTR_BOOLEANFME_ATTR_INT8FME_ATTR_UINT8FME_ATTR_INT16FME_ATTR_UINT16FME_ATTR_INT32FME_ATTR_UINT32FME_ATTR_REAL32FME_ATTR_REAL64FME_ATTR_REAL80FME_ATTR_STRINGFME_ATTR_ENCODED_STRINGFME_ATTR_INT64FME_ATTR_UINT64.
For FME_ATTR_ENCODED_STRING only, the user can specify a character encoding (e.g. 'iso-8895-1'). Otherwise, the encoding argument is ignored.

Parameters: 
  • 1attrName
     (string)
  • 1attrType
     (int)
  • 1attrEncoding
     (string, optional) - defaults to 'utf-8' if attrType is FME_ATTR_ENCODED_STRING and attrEncoding is not set 
Returns: 
1None
Raises: 
  • 1FMEException
     - An exception is raised if an error occurred, e.g. when the conversion failed.
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.

1 reply

bruceharold
Supporter
Forum|alt.badge.img+18
  • Supporter
  • August 10, 2017

Yes, especially for dynamic writing workflows, very handy.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings