cancel
Showing results for 
Search instead for 
Did you mean: 

Counting Empty Sets

ksalem
New Contributor II

Hi All,

I’m looking to build a simple pipeline which can count the number of files in a directory, I have used the ‘Directory Browser’ Snap and ‘Aggregate’ snap (Count Function) and this works well. however I am struggling to get any output when there is no files in the directory. I have tried setting the ‘ignore empty result’ but I am unable aggregate the output of this result set.

Any suggestions for how to pass this condition. fairly sure there will be an obvious solution I am missing :). possible with a conditional snap but not sure how to determine if results are empty/null

Many thanks,
Kareem.

2 REPLIES 2

stephenknilans
Contributor

If you setup a JSON formatter WITHOUT setting the ignore empty result, an empty result will be returned as: . This works even if you have a filter preventing it. If you let data through… you get something more like: [{“test”:“HELLO”}]

Steve

Schevus
New Contributor III

You can add a json generator that generates one dummy record and union that to your directory browser, and then offset your count by 1. That way you always have a document to process for your snaps to execute.