Skip to main content

Hi!

I would like to change a value from a list based on the fme_attrib_info{}.field_name.

For example I have :

fme_attrib_info{0}.field_name : PROJ with

fme_attrib_info{0}.field_value : value1

I would like to do : If fme_attrib_info{x}.field_name = PROJ so change value1 by value2.

I have a lot of attributes so I have to call the attribute by his name and not by the index manually.

I thought to PythonCaller but maybe it exist a transformer for that.

 

Thanks!

Hi @alc33,

You could use a ListExploder to explode the list into its component parts, test each part, then rebuild the list with an Aggregator. This works best if you remove the geometry and other attributes first, then FeatureMerger the rebuilt list back onto a copy of the original features.

You could also set up a looping custom transformer to loop through the list element to do the test and replace.

However, a simple loop in a PythonCaller is probably the simplest and fastest solution, especially since you can read an entire FME list attribute into a Python list with a single FMEFeature.getAttribute() call.


This worked for me:

  1. Use an AttributeCreator transformer to create an attribute fme_attrib_info{@Value(_list_index)}.field_name
  2. Set its value to the value2 attribute.
  3. For large attribute lists you can find the _list_index using a ListSearcher transformer.
  4. You will have to enter the text in a texteditor (notepad or so) first and copy/paste it into the New Attribute field, since AttributeCreator won't let you change the pre-set integer index values. 

 

 

 


Reply