Skip to main content
Solved

Expose attributes that match a pattern


Forum|alt.badge.img+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.

Best answer by david_r

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.

View original
Did this help you find an answer to your question?

4 replies

ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • October 11, 2016

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.


david_r
Evangelist
  • Best Answer
  • October 11, 2016

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.


Forum|alt.badge.img+1
  • Author
  • October 11, 2016
david_r wrote:

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!

eduardojsilvajr
ebygomm wrote:

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.


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