Skip to main content
Hello, i've been struggling with an issue that probably has an answer in Schema Mapper;

 

 

I have around 30 shapefiles, 1 million (ish) features in each, that have a CATEGORY attribute and a CODE attribute, amongst many other things. The thing that makes them unique is that their file name is the year of generation (1994, 2006 etc) and there is also an attribute called year with the corresponding year in it for every feature, for clarity.

 

 

I simply want to rename CATEGORY to CATEGORYXX, where XX represents the last two digits of the year being processed - e.g. CATEGORY94 or CATEGORY06, and do the same for CODE - eg CODE94 etc. 

 

 

That is simple and fine with AttributeRenamer or Creator or SubstringExtractor but i cannot go through all 30 files changing the attribute on the writer to be CODE91 then CODE 92 etc etc, especially when they may need processing more than once in the future. 

 

 

So I set up a dynamic workbench but obviously if you predefine an attribute on the writer, it will not be dynamic anymore.  I am very much struggling to use the SchemaMapper to achieve this simple task. Example 7 here (http://fmepedia.safe.com/articles/Samples_and_Demos/Mapping-Schemas-using-SchemaMapper) is probably in the right ball park but it is claiming that my schema.csv must expose fme_feature_type for all records? all 30 million?! 

 

 

I think i might not be able to see the wood for the trees here, any help?
Yes, one big omission in FME.

 

Dynamicaly created attributes must be exposed.

 

(I think this is like tcl, variables are in memory and s are lost when u exit program.)

 

 

The only way to do this is by dynamicaly creating a schema.

 

This involves python or tcl (if im not mistaking VB-script in fme 2014 also?) and workspacecaller, filewriting.

 

 

Search for "dynamic attributes" on the site. There are examples, for instance by mr. Takashi.

 

 

 

Gio
Hi,

 

 

In this case, renaming attributes will not be so difficult since you need only to add suffix to them. I would use the BulkAttributeRenamer with this setting.

 

Rename: Selected Attributes

 

Selected Attributes: CATEGORY, CODE

 

Action: Add String Suffix

 

String: <specify attribute which stores the 2 digits>

 

 

The question is how to provide a schema source to the dynamic schema writer.

 

Creating a custom format might be a solution. It's hard to explain all the steps here, so I uploaded some files including workspace example for creating a custom format (FME 2014 SP1 build 14287).

 

https://safecommunity.force.com/069a0000003eIZM

 

 

See "SchemaProvider.fmw" at first. There is explanation in an annotation box of the workspace.

 

 

Unfortunately there are few documentations regarding how to define custom format as a schema provider. But these articles could be helpful.

 

http://fmepedia.safe.com/articles/How_To/Extracting-a-schema-subset-for-dynamic-schemas

 

http://fmepedia.safe.com/AnswersQuestionDetail?id=906a0000000cokTAAQ

 

http://fmepedia.safe.com/AnswersQuestionDetail?id=906a0000000coqvAAA

 

 

Takashi

Reply