Can I stop a Flow from emailing a CSV if there are Zero Rows?

Hi - I am stuck and hoping someone can help…

After filtering an INPUT.CSV I sometimes get zero matching rows - so just a header row is left.

Is there a simple way I can check if the data set is ‘empty’ and terminate the flow at this point and stop the “Email a CSV Attachment” step from running and sending me an empty CSV?

Cheers in advance


Hello @Charlie_Muir!

That’s an interesting question. To clarify on the expected behavior of the step Email a CSV attachment, a flow will run and use credits even if there are 0 rows by the time it reaches the end if it ends with this export. A CSV file isn’t emailed if the data set reduces to 0 rows by the time it reaches Email a CSV attachment. You can check if a flow with this export ran and used credits, despite not receiving a CSV file, by going the flow’s Live mode section Run History for an entry with (0 rows).

If you’re seeing a flow’s Live Run History section with entries of (1 row) (or any number greater than 1), this means a CSV file was emailed.

To clarify, are you noting that after your flow ran, you received a blank-appearing CSV file with a header row in it? Can you screenshot or explain what you’re seeing in your flow’s Email a CSV attachment step? If the file you’re receiving is completely blank (no headers), we’re happy to troubleshoot with you to find a solution.

Thanks @Adeline and I will try to add some more info:

The CSV that is being processed has a header row and multiple rows of data below. When I apply a row filter it can reduce the data rows to zero and leave only the header row. This still counts as (1 row) and is emailed to me as CSV - but in effect the CSV is ‘empty’ of data.

I need the Header row in when there is 1 or more data row bit dont want a CSV that only has a header row - I hope this makes sense?

I was wondering if there was a way to stop the flow if Total Rows=1 or if Cell A2= Null

I am very happy to use a credit to run the flow as it will have completed the task required and take the daily noise away from me :slight_smile:


@Charlie_Muir thanks for clarifying on that! A flow with only a header row by the end of it should be displaying in the Live Run History with (0 rows) entry and a CSV file wouldn’t be emailed. If I’m understanding this correctly, it sounds like you’re emailed a CSV and the Run History is labeling a header row as (1 row). Can you email the link to this flow and the empty-looking CSV file next time this happens? We’ve tried and aren’t able to reproduce this experience in tests, though will be happy to investigate why it repeated if it occurs again for you. :slight_smile: