Skip to main content
Solved

Is there a way to log an error when no features in input file or when feature type not exists ?


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.

Best answer by takashi

The NoFeatureTester from FME Hub might help you.

View original
Did this help you find an answer to your question?

8 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

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


takashi
Influencer
  • Best Answer
  • April 30, 2019

virtualcitymatt
Celebrity
Forum|alt.badge.img+36
takashi wrote:

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.

 

 


ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • April 30, 2019

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


  • Author
  • April 30, 2019
ebygomm wrote:

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 !


  • Author
  • April 30, 2019
takashi wrote:

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.


  • Author
  • April 30, 2019
nielsgerrits wrote:

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.


kidega
Contributor
Forum|alt.badge.img+8
  • Contributor
  • April 11, 2023
ebygomm wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings