How to check if the content of a file is empty or not?

NishimuraChinatsu-9854 756 Reputation points
2023-04-07T09:30:20.5+00:00

If the file is empty, I want to proceed to the delete activity; if not empty, I want to proceed to the next activity. I would like to segregate the empty data files, as they are always created. User's image

If you have any suggestions on how to do this, please let me know.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,373 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bhargava-MSFT 31,261 Reputation points Microsoft Employee Moderator
    2023-04-10T19:49:58.75+00:00

    Hello NishimuraChinatsu-9854, You can achieve this by GetMetadata activity to get the number of rows in the file. If the number of rows is zero, then the file is empty. Please see the below steps:

    • add Get Metadata activity to get the number of rows in the file.

    Field list - Column count

    • If Condition activity to check if the number of rows is zero.

    Expression: @equals(activity('Get Metadata1').output.count, 0)

    • If the number of rows is zero, proceed to the Delete activity.
    • If the number of rows is not zero, proceed to the next activity.

    To segregate the empty data files, you can use the Filter activity to filter out the files with zero rows and move them to a separate folder.

    • Get Metadata activity to get the number of rows in the file.
    • Filter activity to filter out the files with zero rows.
    • Copy activity to copy the filtered files to a separate folder.
    • Delete activity to delete the filtered files from the original folder.

    User's image

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.