Skip to main content
Solved

ListKeyValuePairCreator

  • June 26, 2024
  • 2 replies
  • 52 views

erik_jan
Contributor
Forum|alt.badge.img+23

Hi all,

I am looking for a transformer that does the opposite of the ListKeyValuePairExtractor.

It needs to create a list with FIELD_NAME and FIELD_VALUE pairs for all the attributes on a feature.

I checked the transformer gallery and the FME Hub, but could not find such a transformer.

Has anybody a solution?

Could be a Python script.

 

Thanks in advance.

Erik

Best answer by debbiatsafe

Hello @erik_jan 

If you are looking for a transformer that can create a list structured like:

_list{0}.FIELD_NAME = "Field 1"
_list{0}.FIELD_VALUE = "Value 1"
_list{1}.FIELD_NAME = "Field 2"
_list{1}.FIELD_VALUE = "Value 2"

Try the AttributeExploder with the Exploding Type parameter to ‘List’. You should be able to select the name of the output list as well as the name of the exploded attribute and value in the Output Attribute Names parameter section.

If you are looking to create a list that looks like:

_list{0}.FIELD1 = "Value 1"
_list{0}.FIELD2 = "Value 2"

Then try the ListBuilder.

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.

2 replies

debbiatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • Best Answer
  • June 26, 2024

Hello @erik_jan 

If you are looking for a transformer that can create a list structured like:

_list{0}.FIELD_NAME = "Field 1"
_list{0}.FIELD_VALUE = "Value 1"
_list{1}.FIELD_NAME = "Field 2"
_list{1}.FIELD_VALUE = "Value 2"

Try the AttributeExploder with the Exploding Type parameter to ‘List’. You should be able to select the name of the output list as well as the name of the exploded attribute and value in the Output Attribute Names parameter section.

If you are looking to create a list that looks like:

_list{0}.FIELD1 = "Value 1"
_list{0}.FIELD2 = "Value 2"

Then try the ListBuilder.


erik_jan
Contributor
Forum|alt.badge.img+23
  • Author
  • Contributor
  • June 27, 2024

Thanks @debbiatsafe ,

That worked perfectly.

Exactly what I needed.

Erik