Skip to main content


List one contains the attribute names

IndexAttribute_namejoin0Incidenttype11keyword12region13regionrefinment14location15reporting16verified17closed18advisory19interest110notification111security112status1



List two contains the attribute values

IndexAttributejoin0enviromental11storm 12north america13canada14eastern ontario15jtfc16false 17false 18xxxxxxxx19high110stratadvisory111unclass112initial1



The goal is to append the two lists to the feature below.

joinmodtimetaskoriginlonglatnametypestatusstarttimeentid118:06jttr44.245707-77.50707stormeffectex0.010x0008e



I have tried various transformers to create a new feature
using the two lists and then merging the features without success.


Is the first list dynamic? (I mean is it likely to change from one run to the next, or even from one feature to the next)

 

 


End state should look like the below. The lists are not dynamic.

 

joinmodtimetaskoriginlonglatnametypestatusstarttimeentidIncidenttypekeywordregionregionrefinmentlocationreportingverifiedclosedadvisoryinterestnotificationsecuritystatus118:06jttr44.24571-77.5071stormeffectex0.010x0008eenviromentalstorm north americacanadaeastern ontariojtfcfalse false xxxxxxxxhighstratadvisoryunclassinitial

 

 


Ok, if the lists are always the same you can simply use an AttributeManager to create new attributes and fill them with the list elements.

Dynamically creating the attributes is possible, there's some hints on how to do that here


You can have a look at the ListKeyValuePairExtractor custom transformer created by @sander


Ok, if the lists are always the same you can simply use an AttributeManager to create new attributes and fill them with the list elements.

Dynamically creating the attributes is possible, there's some hints on how to do that here

Not working for me. The first list is the attribute name and the second is the attribute value. I have tried the attributemanager with the listbuilder and listexpolder as the source and in no scenario have I been able to get to my end-state.

 

 


You can have a look at the ListKeyValuePairExtractor custom transformer created by @sander

I do not have access to custom transformers in our environment.

 

 


Ok, if the lists are always the same you can simply use an AttributeManager to create new attributes and fill them with the list elements.

Dynamically creating the attributes is possible, there's some hints on how to do that here

Since the lists are not dynamic, after populating attribute values from the List 2 into a list attribute, you can just create new attributes and set the value of list elements to them for each, with the AttributeManager or the AttributeCreator.

 

  • "Incidenttype" = value of "_list{0}.Attribute"
  • "keyword" = value of "_list{1}.Attribute"
  • "region" = value of "_list{2}.Attribute" ... and so on.
Alternatively, you can also rename each element with the AttributeManager or the AttributeRenamer.

 

  • Rename "_list{0}.Attribute" to "Incidenttype"
  • Rename "_list{1}.Attribute" to "keyword"
  • Rename "_list{2}.Attribute" to "region" ... and so on.
Anyway I don't think it's necessary to use the List 1, if it's sure that the schema is static.

 

 


For a static list, @redgeographics is correct, you an use an attributeManager, either hardcoding the attribute name incidenttype = @Value(list2{0}), or for a bit of flexibility @Value(list1{0}) = @Value(list2{0}).

 

 

For dynamic lists, you can go old school with the FMEFunctionCaller  @SupplyAttributes(@Value(list1{0},@Value(_list2{0}))

 

or use a bit of python

 

    nameList = feature.getAttribute('_list0{}')
    valueList = feature.getAttribute('_list1{}')
    
    for i, attrName in enumerate (nameList):
        feature.setAttribute(attrName, valueListui])

Ok, if the lists are always the same you can simply use an AttributeManager to create new attributes and fill them with the list elements.

Dynamically creating the attributes is possible, there's some hints on how to do that here

Thanks, I am trying to use list1 to populate the attribute name field. Whenever I use the _list{#}.attributename notation in the new attribute field of the attribute-creator or attribute-manager I get a "<no schema>" in the result set. If I hardcode an attribute name and put a _list{#}.attribute in the value field it works. Is it possible that the add attribute cannot read a list?

 

 


Thanks, I am trying to use list1 to populate the attribute name field. Whenever I use the _list{#}.attributename notation in the new attribute field of the attribute-creator or attribute-manager I get a "<no schema>" in the result set. If I hardcode an attribute name and put a _list{#}.attribute in the value field it works. Is it possible that the add attribute cannot read a list?

 

 

See @jdh's last suggestion.

 


Reply