Counting rows of a CSV file using Get Metadata in Azure Data Factory

Aditya Singh 135 Reputation points
2024-08-26T07:43:21.08+00:00

How can I use Get Metadata activity in Azure Data Factory to count the number of rows of a CSV file? I need to perform this task as part of my pipeline but cannot find a suitable solution. Any suggestions or examples would be greatly appreciated.

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.
4,863 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,573 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Nandan Hegde 32,026 Reputation points MVP
    2024-08-26T08:49:48.56+00:00

    Hey,

    Not sure whether 1 can use get meta data activity to get the row count.

    You can use the below options:

    1. Lookup activity: but there is restriction of 5000 rows
    2. Dataflow : [Source (csvfile) -> DerivedColumn (rowcount) -> Aggregate (count(rowcount)) -> sink (cache the output of aggregate)]
    3. use copy activity and copy the data from csv into a SQL table and use :
         @activity('Copy data1').output.rowsRead
      
    1 person found this answer helpful.

  2. AnnuKumari-MSFT 32,816 Reputation points Microsoft Employee
    2024-08-29T06:22:03.27+00:00

    Hi Aditya Singh ,

    Thankyou for posting your query on Microsoft Q&A platform. As per my understanding you want to get the number of rowcount in ADF .

    Other approach apart from the one shared by Nandan , would be to use a single copy activity to load the file from one folder to another within your ADLS and capture the rowsread property from the copy activity output.

    You can use the below expression for achieving the requirement:

    @activity('copyActivity').output.rowsRead
    
    

    Here is how the output of copy activity would look like: enter image description here

    Hope it helps. Kindly accept the answer by clicking on Accept answer button. Thankyou

    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.