Skip to main content
Question

How can i append to lists to a feature


jurgenmack
Contributor
Forum|alt.badge.img+9

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.

10 replies

redgeographics
Celebrity
Forum|alt.badge.img+49
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)

 

 


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • March 19, 2018
End state should look like the below. The lists are not dynamic.

 

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

 

 


redgeographics
Celebrity
Forum|alt.badge.img+49

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


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • March 19, 2018

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


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • March 19, 2018
redgeographics wrote:

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.

 

 


jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • March 19, 2018
jdh wrote:

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

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

 

 


takashi
Influencer
  • March 19, 2018
redgeographics wrote:

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.

 

 


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • March 19, 2018

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, valueList[i])

jurgenmack
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • March 19, 2018
redgeographics wrote:

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?

 

 


takashi
Influencer
  • March 19, 2018
jurgenmack wrote:
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.

 


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