4

I have an FME workbench which uses a python parameter to copy an existing file geodatabase from one location to another and uses the copy as the writer. This geodatabase has about 50 empty feature classes with fields defined.

The input of the workbench is a folder of shapefiles which each get mapped to the appropriate feature classes using a SchemaMapper transformer.

What I want to do is delete the empty feature classes from the geodatabase after the workbench completes. I have ArcGIS installed on the same machine and I have been successful at deleting the empty feature classes using arcpy in an FME Shutdown Script.

The script I'm using is:

for dirpath, dirnames, filenames in arcpy.da.Walk(env.workspace, datatype = 'FeatureClass'):
    for filename in filenames:
        fc = os.path.join(dirpath, filename)
        featureCount = int(arcpy.GetCount_management(fc).getOutput(0))
        if featureCount == 0:
            arcpy.Delete_management(fc)
            print "deleted {0}".format(fc)

However, I was wondering how I could achieve this without the use of arcpy? What would I need to do to delete the empty feature classes using only the tools available in FME?

I'm using FME 2016.0.1.

  • Am I right, that your workbench should read some input features and CREATE the database and the destination feature classes? Until FME 2015 (I have no experience with FME 2016) the standard behaviour is that when no feature arrives at the input of the writer, the feature class is not created. – Propper Mar 10 '16 at 6:45
  • No, there is already a template geodatabase that exists. I have a python script that copies it to another location and uses that as the destination gdb for the writer. All feature classes in the template are empty. – Fezter Mar 10 '16 at 6:46
  • Can you read the original template geodatabase in the same workbench you read the shapefiles? You could create a dynamic writer using the schema of the "template database reader". Connect the shape file data to this writer, too. The Writer creates the new database and the FME creates only the feature classes with data. So you don't need to delete the empty feature classes an you don't need copy the template geodatabase any more. Otherwise I don't no a way to delete an empty feature class by using FME excepting the (not that bad) Shutdown Python Script approch. – Propper Mar 10 '16 at 7:13
  • I don't know it will help with the empty table removal, but is there a particular reason you use a script to copy the geodatabase for use in a Writer? Could you not just use the Template Geodatabase parameter in the Writer to point to the existing geodatabase? – Mark Ireland Mar 28 '16 at 18:51
  • Of course I could! I totally forgot about that option. I'm going to try that when I get back to the office. Thanks. – Fezter Mar 28 '16 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.