Forum Discussion
5 Replies
- bojanvelevskiValued Contributor
I think the Filter snap will do the job. For your first use case, If you want to check if some of the fields has a specific value, you’ll need something similar to this:
$Record == 'Required Value'
If your requirement is to check if you have any records at all, you can either group the records in an array, and count its length, or use an Aggregate snap after the CSV Parser/SQL reading, select the COUNT Function and add a result field , than again use the Filter snap with the following expression:
$ResultField > 0
Hope this helps,
Regards,
Bojan - amit_trivediNew Contributor
Thanks for the reply.
If I use aggregate snap, it will change the structure of my data. I just wanted to check if my file(to be loaded) has records then load the entire file else exit the pipeline.
Is there a way to count records in a csv(without using Aggregate snap) which I would use in a Router. If the value>0 then load the file else exit the pipeline.
Kindly suggest.- rajesh_mangipudNew Contributor II
File Reader Snap gives a “content-length” field, which when 0 means an empty file. You can use a Binary Router Snap to route the empty and non-empty files. Alternatively the CSV Parser Snap has an option to Ignore Empty data, which when enabled stops the execution.
For SQL Table, the SQL Server Select snap has an option to Ignore empty result, which when enabled stops execution
- amit_trivediNew Contributor
Thanks.
The “content-length field” is not visible in the expressions in binary router snap. - bojanvelevskiValued Contributor
Try
$.hasPath('input')
, where ‘input’ is one of the fields you are reading either from the csv or sql.