Skip to main content
Question

Make a Dictionary

  • August 22, 2013
  • 4 replies
  • 135 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

4 replies

fmelizard
Safer
Forum|alt.badge.img+18
  • 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
Influencer
  • 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.

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