Skip to main content
Archived

Python API: new setAttributeType() method for FMEFeature class

  • August 10, 2017
  • 1 reply
  • 83 views

geosander
Forum|alt.badge.img+7

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: 
  • attrName
     (string)
  • attrType
     (int)
  • attrEncoding
     (string, optional) - defaults to 'utf-8' if attrType is FME_ATTR_ENCODED_STRING and attrEncoding is not set 
Returns: 
None
Raises: 
  • FMEException
     - 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
Influencer
Forum|alt.badge.img+19
  • Influencer
  • August 10, 2017

Yes, especially for dynamic writing workflows, very handy.