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.