How to simplify the logic to grab multiple files with similar naming pattern?

King Java 790 Reputation points
2023-01-20T02:15:45.57+00:00

I have following 9 csv files:

User's image

In Azure Data Factory, I have been using 9 individual pipelines with each one with a wildcard to grab files like this:

@concat('CA_Employee_List_1',formatDateTime(utcNow(),'MMddyyyy'),'*','.csv')

....

@concat('CA_Employee_List_9',formatDateTime(utcNow(),'MMddyyyy'),'*','.csv')

But, rather than having 9 separate pipelines, I would like to use ForEach or something dynamic way to grab all 9 files in a better method so I could possibly only use 1 pipeline.

What is an approach to go thru each file name using a wild card like indicated on the top?

Currently, I only have two activities (Copy data --> Stored Procedure):

User's image

Just FYI:

I believe if I use "Get Metadata" activity, I cannot use wildcard.

So, I have been using "Lookup" activity for looking at file name (for other pipeline).

User's image

Thanks.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,655 questions
0 comments No comments
{count} votes

Accepted answer
  1. Nandan Hegde 36,156 Reputation points MVP Volunteer Moderator
    2023-01-20T03:48:39.3+00:00

    Hey,

    you can use Range function :

    [https://learn.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions#range

    to create an integer array from 1-9 and use a for each iteration with range array as input.

    You can create a dynamic source dataset with parameterized dataset where @concat('CA_Employee_List_',item(),',formatDateTime(utcNow(),'MMddyyyy'),'*','.csv')

    1 person found this answer helpful.

0 additional answers

Sort by: Most 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.