Skip to main content

Hi,

I published a workspace to the FME Server (2018) of my client that allows to import a specific sheet of an Excel file in Postgres.

But when the input file has zero feature or when the specific sheet doesn't exists, the Workspace doesn't log any error and says that translation was successfull.

Of course, we could open the Excel file to check the data but this workspace is running with automatic processes.

Is there a way to log an error when there are no features in the input file or when the awaited feature type (Excel sheet) not exists ?

Thanks for any help.

With the FeatureReader transformer you can check for schema features. In Excel the worksheet is a schema. This way you can test if a sheet exists.

testforsheet2019.fmwt


The NoFeatureTester from FME Hub might help you.


Fantastic transformer! This is an excellent solution for these kinds of problems. What I like to do (if i'm expecting data to be written out) is to stick this python into a shutdown script. It's great for the FME Data Download service which has a habit of creating bad links.

 

 

#This shutdown script is used to catch unhandled excretions. This is the case when the workspace reports a 'Success', however, no features were written out. 

import fme
FeaturesWritten = str(fme.featuresWritten)
#print(FeaturesWritten)
status = fme.status
#print(status)
if status == 1 and FeaturesWritten == "{}":
    print("no data output - unhandled exception")
    raise Exception("unhandled exception")

It wont work if you are writing data with a feature writer, however, if working with normal writers it is a handy script.

 

 


I use a pythoncaller to create a feature if no input features exist - then send to a terminator/excel log etc.


I use a pythoncaller to create a feature if no input features exist - then send to a terminator/excel log etc.

Thank you for this tip, I keep it in mind but Takashi's solution is more simple and works exactly as I want. Have a good day !


Thank you once again Takashi, I couldn't expect that a Transformer would do the trick as there is no feature coming out from the reader but I tested and it works perfectly as I want.


With the FeatureReader transformer you can check for schema features. In Excel the worksheet is a schema. This way you can test if a sheet exists.

testforsheet2019.fmwt

Thanks, it's an interesting tip to use the UnmergedRequestor output from a FeatureMerger !

But NoFeatureTester is more simple and do the work perfectly ;)

Have a good day.


I use a pythoncaller to create a feature if no input features exist - then send to a terminator/excel log etc.

Thanks for this suggestion @ebygomm​ ! It too works well for my intention.


Reply