Skip to main content
Question

Forcing FME Form to write out an empty .tab file based on null TestFilter results

  • 22 July 2024
  • 3 replies
  • 27 views

Hello Forum,

 

I have a workspace which consumes an incoming geojson and then outputs three .tab files based on datestamp value combinations (via TestFilters):

 

  • Active sites – where the start_date datestamp is in the past and the end_date datestamp is in the future
  • Closed sites - where the start_date datestamp is in the past and the end_date datestamp is in the past
  • Upcoming sites - where the start_date datestamp is in the future past and the end_date datestamp is in the future

 

This workspace is doing exactly what I want it to do, so far.

 

However, it’s entirely possible that there may be occasions when no object falls into one of the categories (e.g.: Upcoming sites). At the moment, if that happens then the workspace does not create an output. In this scenario I’m left with the most recent previously created output, where there were Upcoming objects. But in this scenario I need the workspace to create a tab output , but with no objects within it.

 

Is it possible to programme this in into the workspace? Perhaps within the FeatureWriters?

 

Thanks,

Stuart

3 replies

Badge +41

I believe there is no out of the box method to do this. (Creating an empty file.) The (Feature)Writer needs a feature as input, so you’ll always end up with a file with a dummy feature. The following proces will need to understand that this is a dummy feature and needs to be ignored.

The easiest way to achieve this is to test if you have output, and if you have none then generate a dummy record to sent to the writer. Several ways to do this but the NoFeaturesTester from the fme hub is created to do this.

If the data format accepts editing (like a file geodatabase) it is possible to remove the dummy record after the file is created, using another FeatureWriter. (I have no experience with MapInfo so I don’t know if editing the created file is supported, but I think this is not the case.)

Alternatives I can think of are:

  • If no features, use Python to create an empty MapInfo file.
  • If no features, use a File Copy Writer to copy paste an empty file from another directory to the output directory.
Userlevel 2
Badge +7

Thanks for those suggestions, @nielsgerrits 

 

Userlevel 2
Badge +7

Hi @nielsgerrits The NoFeaturesTester transformer is very useful. It does exactly what’s required. 

Reply