Skip to main content
Question

Make a Dictionary

  • August 22, 2013
  • 4 replies
  • 176 views

I have four attributes coming out of a feature reader and I want to combine three of them into a key with the fourth as a value in a dictionary, something like:

 

 

dictCost = [{"att1::att2::att3" : att4},{"att1::att2::att3" : att4},{"att1::att2::att3" : att4}]

 

 

I know that I can do this in Python, but can I build a dictionary or string-indexd array this way in "straight" FME?

 

 

Thanks
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.

4 replies

fmelizard
Safer
Forum|alt.badge.img+21
  • Safer
  • August 22, 2013
Hi,

 

 

I would look into the string concatanetor or attribute creator for that for the FME way, otherwise you can always use python in a python caller.

 


  • August 22, 2013
I know that I can build the key with the string concatenator. However, I want to build a string indexed array so I can access the value of a given concatenated key. However, FME seems to have only numeric arrays, not a string-indexed array like a Python dictionary.

takashi
Celebrity
  • August 23, 2013
Hi,

 

 

FME cannot build a string-indexed dictionary except in Python script. But in many cases, I think a dictionary-like functionality can be realized via FeatureMerger.

 

If those three attributes were concatenated, the features itself can be considered as a dictionary. That is to say, you can append "att4" associated with a specified key value to any feature using a FeatureMerger.

 

Is this approach useless in your situation?

 

 

Takashi

  • August 23, 2013
Using the FeatureMerger as a dictionary is an excellent concept, and that's what I wound up doing. As you have said, when the:

 

 

attr1::attr2::attr3  

 

 

...key matches, then I have attr4 as the value.

 

 

Still, it would be nice to have an FME string-indexed array structure.