4

I have an FME workspace which reads a folder of MapInfo TAB files and writes them to a File Geodatabase. The reader and writers are both using dynamic schema as I need to run this workbench on multiple folders each containing several files.

What I would like to do is add an attribute to the feature class which contains the file path of the input TAB file. I have exposed the fme_dataset attribute on the reader and I have added it to the writer as well. That didn't work. I've also tried copying the fme_dataset attribute to another attribute called File_Path. That didn't work either.

I'm assuming that this isn't working because the schema definition is coming from the reader. But, why won't it work even when I expose the fme_dataset attribute?

I've looked at this similar post on FMEPedia, but I don't see how I can use a schema mapper for this purpose.

EDIT 07/01/2014

I thought this might be relevant as well, so I'll add the following:

I have created a separate attribute called FeatureClassName which is just the source file name which has been validated (removes non-word characters such as brackets). In the dynamic properties for the destination geodatabase, I have used a custom schema definition:

enter image description here

I am setting the Feature Type Name from that attribute:

enter image description here

The Schema definition is set to default (from Feature Type Name - above). Is it possible that this could be the reason I'm not able to add the attribute?

asked Jan 6, 2014 at 6:45

3 Answers 3

2

I'm going to disagree with Ken here (sorry Ken) and say this should work as you describe. If you add a new attribute to a dynamic schema it should get added to the output.

In fact, I've tried it myself and it seems to work, so I don't know why it isn't happening for you. I've posted my example to Dropbox for you to check out. It uses 2014 but the same technique should be good in earlier versions. The only difference to your scenario is that I'm using a fixed (not dynamic) reader.

When you say it doesn't work, is the attribute not added at all, or is it added but with an empty/missing value? I think that's an important distinction to help diagnose the problem. If the latter then check your schema field is large enough (it might be dropped rather than truncated) but I'm dubious that would be the cause.

If that fails to help I suggest talking to our support team.

answered Jan 6, 2014 at 16:12
5
  • Actually, I guess another difference is that I'm using Shape not Geodatabase as the output. Perhaps that is the problem, though I don't think it should make a difference. Commented Jan 6, 2014 at 16:14
  • Yep Mark's is a way better way to do this! I didn't realize that worked ;-) Commented Jan 6, 2014 at 16:19
  • 1
    This is great having Safe peeps compete for answers, maybe ya'll should make a contest out of it -- person with the most upvotes at the end of each month gets a bonus :) Commented Jan 6, 2014 at 18:49
  • @MarkIreland, yes, that's essentially what I tried. I have done that several times in the past with no trouble. And to answer your question, the attribute doesn't actually get added to the destination feature classes. I will send my workspace to support. Commented Jan 6, 2014 at 23:23
  • I've also edited my question with additional information which may be relevant. Commented Jan 6, 2014 at 23:31
1

This is tricky but possible in later builds of FME 2013 and FME 2014. You can get the schema in a different way, by adding a SchemaReader to your workspace which has its source parameter linked to read the same source as your MapInfo reader. The schema reader gets the schema from the files you are reading and then we can provide the schema as a list attribute to the dynamic writer. The trick is that you can add your additional File_Path attribute to the list. The list must be called 'attribute' and contains the attribute names and data types that the dynamic writer can use. The list is added to each attribute going to the writer. The list might look something like this:

attribute{0}.fme_data_type = fme_int32
attribute{0}.name = PRIMARYINDEX
attribute{0}.native_data_type = int32
attribute{1}.fme_data_type = fme_varchar(50)
attribute{1}.name = File_Path
attribute{1}.native_data_type = char(50)

Then on your actual features you would have created the File_Path attribute by exposing and renaming fme_dataset. Join this list to your actual features before the writer.

The other catch is that you need a null reader as a Workspace resource and this "null" reader is set as the schema source for the Dynamic Writer in the destination feature type properties.

I have placed a workspace here that seems to work - probably easier than trying to follow my long winded explanation: https://www.dropbox.com/s/6c815551p3h6joc/AttributeDrivenDynamic.zip

Hope this helps,

Edit January 6th 2014 (later same the day) There was an issue in the workspace download which I just fixed. For the source MapInfo feature type you need to have "Merge Feature Type" checked and filter set to * so that MapInfo files with any name can pass through.

answered Jan 6, 2014 at 11:01
0

You may use the FileNamePartExtractor transformer. You can assign the Directory Path filename part to the fme_dataset. This transformer output may then be pulled into your writer as input.

enter image description here

answered Jan 6, 2014 at 12:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.