How to unzip csv files, read first line, load into different tables based on the first line content using ADF?

KT 0 Reputation points
2024-06-27T09:19:17.7366667+00:00

I have Zip folder in Azure container in which we have multiple CSV files.

I want to:

  1. Unzip CSV files
  2. read first line of each file one by one to find text 'XYZ'.
  3. based on findings i want to route the file data into two different tables (one with 'XYZ' and another without 'XYZ'). Please let me know how we can achieve this?

Thank you in advance!

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,785 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Matt Arnold 85 Reputation points
    2024-06-27T09:24:54.15+00:00

    I can help with that, Abhishek! ADF doesn't have a built-in unzip activity, but you can combine the Copy Activity and Data Flow to achieve this. Here's a general approach:

    1. Use Copy Activity to unzip the folder and iterate over each CSV file.
    2. Inside a loop (ForEach Activity), use Data Flow to:
    • Read the first line using a Data Flow source.

    Use a conditional split based on the presence of "LOCATION".

    Route data to appropriate sink tables (one for "LOCATION", one for others).

    For reference, to find out the cost of getting a composite door fitted in the UK, you can search online for how much is a composite door fitted UK?

    1 person found this answer helpful.

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.