Skip to main content
Solved

Generic dynamic reader: Attributes missing

  • November 3, 2015
  • 9 replies
  • 127 views

Hi,

 

 

I am trying to build a workbench that performs certain checks irrespectively of the Input data. That means that it must accept data with different data types (.shp, .mdb...) and schemes (e.g. different attribute names and types). As far as I know, a generic dynamic reader is what I need. So I inserted one and tested it. Although this reader reads the (spatial) data and shows its polygons in the inspector, the attributes are lost. Instead of the original attributes, there is only one row in the table with the header <no schema>. In the feature information part of the inspector, however, the attributes are still listed. Since I want to write a log file including all the errors found by the checker, the attributes are important. What do I need to do, so that I can access the attributes of the generic dynamic reader?

 

 

 

Best regards

 

André

Best answer by mark2atsafe

For the CSV Writer use a dynamic schema to get the original attributes - and the Attribute Definition dialog should also let you add additional attributes for whatever you have created using transformers.

 

 

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

9 replies

david_r
Evangelist
  • November 3, 2015
Hi

 

 

You've hit upon the sometimes frustrating difference between run-time and design-time attributes. When using "traditional" readers, the Workbench will automatically expose (make visible) the attributes made available by the reader to the follwing transformers etc.

 

 

When using a dynamic schema, this doesn't happen automatically, since the Workbench GUI doesn't know which objects might or might not pass through. So you will have to design your workspace to be "attribute-agnostic".

 

 

How you do this will vary depending on which transformer you use, e.g. some transformers write out their results in attributes with a constant name, so those are easy to use later on. For other cases you can use the AttributeExploder to split your features up in to key/value pairs and treat them sequentially. This will let your transformers know about any attributes that are only available at run-time.

 

 

Another more powerful, but also more complicted option is to use the scripting abilities in FME using e.g. Python. The excellent fmeobjects module will let you iterate over attributes and manipulate them in a very dynamic fashion that lends itself well to the dynamic schema concept.

 

 

David

 


mark2atsafe
Safer
Forum|alt.badge.img+43
  • Safer
  • November 3, 2015
As David says, the dynamic schema - because it isn't predictable - isn't exposed automatically in Workbench and won't appear in the table view in the DI (although the attributes are there, as you can see by querying a feature).

 

 

If you're going to be testing a specific attribute (say, does this dataset contain an attribute called 'abc') then use an AttributeExposer transformer to expose 'abc'. Then use a Tester to test 'Attribute is Missing'.

 

 

If you want to write out the data - regardless of schema - then you'll need to add a dynamic writer to the workspace. That will handle any data that the dynamic reader reads.

 


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • November 3, 2015
Apart from scripting there is a workspacerunner contruction to do this.

 

Involves attribute exploding/listbuilding and filewriter. A WSR to read the written file.

  • Author
  • November 3, 2015
Thank you very much for your answers!

 

 

Since I need the original attributes only to indicate which features are affected by the Errors, the solution of Mark seems to be the easiest one. Between the generic dynamic Reader and a CSV-writer, a chain of transformers lies between that ends with loggers. What kind of CSV file definition do I have to set, so that the resulting csv writer includes the original attributes of the reader plus the additionally created ones by the transformes? Automatic or dynamic (advanced)?

 

 

PS: Is it possible to deactivate the built-in spell checker? It always tries to change the English words to German.

 


mark2atsafe
Safer
Forum|alt.badge.img+43
  • Safer
  • Best Answer
  • November 3, 2015
For the CSV Writer use a dynamic schema to get the original attributes - and the Attribute Definition dialog should also let you add additional attributes for whatever you have created using transformers.

 

 


mark2atsafe
Safer
Forum|alt.badge.img+43
  • Safer
  • November 3, 2015
egaru wrote:
Thank you very much for your answers!

 

 

Since I need the original attributes only to indicate which features are affected by the Errors, the solution of Mark seems to be the easiest one. Between the generic dynamic Reader and a CSV-writer, a chain of transformers lies between that ends with loggers. What kind of CSV file definition do I have to set, so that the resulting csv writer includes the original attributes of the reader plus the additionally created ones by the transformes? Automatic or dynamic (advanced)?

 

 

PS: Is it possible to deactivate the built-in spell checker? It always tries to change the English words to German.

 

I've asked and have been told we don't have a spell checker. Maybe it's built directly into your browser?


  • Author
  • November 4, 2015
It works when the reader is set as being dynamic and when "Select all" is chosen in the "select Schema sources items"-dialog. Thank you very much.

helmoet
Forum|alt.badge.img+8
  • February 2, 2017
Would it be possible, in this dynamic and generic environment, for the user to select an attribute that he wants to be processed? Like using an ATTR_NAME type user parameter?

kimo
Contributor
Forum|alt.badge.img+10
  • Contributor
  • March 1, 2020

It is possible with a simple workaround using the WorkspaceRunner to collect a list of attributes, turn them into a concatenated string separated by LF chars and then submit that to another workspace. So you then have a static workspace dynamically defined! You need to use SchemaReader in both workspaces and FeatureReader.


Reply


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