Solved

Expose attributes that match a pattern

  • 11 October 2016
  • 4 replies
  • 3 views

Badge +1

Hello,

I have a set of features, which have specific(but varying) attributes that I want to expose. All these attributes are uppercase, but all features do not have these attributes, and the names of the attributes vary quite a lot. The only thing they all have in common is being upperspace. I can filter them out with the PythonCaller, but I am unsure about how to input them to the AttributeExposer.

The only input I can give the AttributeExposer is to open a file and read from there. Seems like a big workaround to read all the attributes, filter them, then write to a file and then open it.

icon

Best answer by david_r 11 October 2016, 13:01

View original

4 replies

Userlevel 1
Badge +10

You can expose attributes using a featuremerger (not sure whether this is by accident or design).

If you have a file which has all the attributes you wish to expose, you can merge with the data (using 1 so everything is merged) with the featuremerger settings set to accumuldation mode - merge supplier and conflict resolution - use requestor.

Userlevel 4

This is somewhat related to https://knowledge.safe.com/questions/30874/expose-format-attributes-with-values-only.html and https://knowledge.safe.com/questions/32483/dynamic-attributes-in-custom-transformer.html.

The short answer is that you can't, really. At least not easily without resorting to tricks.

You could either continue with the PythonCaller (my preferred solution), or consider a solution using the AttributeExploder, which will let you work with features having attribute names that are unknown when you design the workspace. Just be aware that the AttributeExploder route can be quite demanding on memory resources when <number of features> x <number of attributes per feature> gets bigger, but on the other hand you can do everything without having to deal with Python.

Badge +1

This is somewhat related to https://knowledge.safe.com/questions/30874/expose-format-attributes-with-values-only.html and https://knowledge.safe.com/questions/32483/dynamic-attributes-in-custom-transformer.html.

The short answer is that you can't, really. At least not easily without resorting to tricks.

You could either continue with the PythonCaller (my preferred solution), or consider a solution using the AttributeExploder, which will let you work with features having attribute names that are unknown when you design the workspace. Just be aware that the AttributeExploder route can be quite demanding on memory resources when <number of features> x <number of attributes per feature> gets bigger, but on the other hand you can do everything without having to deal with Python.

 

Python seems like the way to go, yes. I will have a go at attempting to create a schema from the attributes I've read and applying that to the writer in the end. It's also a bit of a workaround, but would at least produce the end result I desire.

 

 

Thanks for the help!

You can expose attributes using a featuremerger (not sure whether this is by accident or design).

If you have a file which has all the attributes you wish to expose, you can merge with the data (using 1 so everything is merged) with the featuremerger settings set to accumuldation mode - merge supplier and conflict resolution - use requestor.

I've tried this in FME 2019 and the featuremerger didn't exposed the attributes.

Reply