Skip to main content
Question

How to (easily) extract an attribute name into the 'value'?

  • November 22, 2023
  • 2 replies
  • 574 views

Forum|alt.badge.img

I am trying to get all the unique values from each field in a dataset. I would like to be able to expose the field name into each record, so I have an output table that looks like this:

 

image.pngI can run a statistics calculator to get the unique values, but the only way I have managed to expose the field name is by using an attribute exploder. This seems a bit messy because it outputs a whole bunch of combinations I am not interested in.

 

In the attribute manager, using @Value(fieldName) will return the actual value rather than the field name itself - are there any tricks using string expressions etc. to expose the actual field name? Seems like a simple thing to do but may be better handled in python. Just wanting to know if it's possible in FME! Would be really handy.

2 replies

ctredinnick
Supporter
Forum|alt.badge.img+19
  • Supporter
  • November 23, 2023

I think the AttributeExploder is your best bet still. I don't know how you can check for unique attribute values without breaking up each attribute into its own feature.

I tried with a SchemaScanner, that'll get your list of Field Names, and you can get your values from each field with a @Value(@Value(name))

imageBut fundamentally that's doing the same thing as an AttributeExploder at that point, it still results in every attribute with every value which you have to filter.


takashi
Influencer
  • November 23, 2023

Hi @kaz​ ,

I agree that AttributeExploder is a quick way.

You can exclude attributes which you aren't interested in from exploding by setting a pattern (regular expression) of their names (e.g. "fme_" etc.) to the Ignore Attributes Containing parameter.

See the help of the transformer to learn more.


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