FME – How to Automatically Delete Unnecessary Attributes from Table in FME 2021

fme-form

I am reading some feature types in FME, doing some processing and writing as ESRI shape file format. Is there a way I could delete all the attributes from a table that are not necessery?? I need my shape files as small as possible (file size). I know python caller can probably do something like this but maybe there is an easier way.

enter image description here

Best Answer

So what's happening here is that you are using what we call "Dynamic" mode. It means that FME automatically outputs exactly the same data that is input (in terms of attributes). The idea is so that you can create a workspace that converts any source dataset, regardless of schema (data model).

Using the AttributeRemover won't help because the output schema is already being set by the input. The reason you get no output at all is because one attribute provides the name of the feature type to write and you're probably removing that attribute. The log would probably say something like "x features didn't match a known feature type and were discarded".

So... do you need to have a dynamic solution? If the source data is always the same in terms of layers and attributes, then the answer is no. What you should do is recreate the workspace without dynamic mode turned on. Then you can manually edit the output feature types to have only the attributes you need.

But... if you do need a dynamic solution then it becomes more complicated. That's because FME needs to know what schema to write, but doesn't know where to get that information, which could vary from run to run anyway. You need to tell FME what to write - for example, you could set up a text file with a list of attributes and use that.

I won't go into the dynamic side too much, because I'm hoping that you don't necessarily need to use it. But if you do, then I can point you to some useful resources that will help.

Oh... please don't resort to the PythonCaller! There should be a non-programmatic way to handle this scenario!