Reputation: 59
In my Azure Data Factory pipeline I have a filter activity where I need to check whether name of a file is matching a specific pattern.
eg: >the file should be a csv file and name should starts with 'D'. >the name of the file must contain a specific word.
These values will come from a config file.
I want the implementation be something like this: My config file will have an attribute called "filePatternt" which will be a regex. In the filter activity, I will extract this attribute and will do something like regex.match(@myregular expression from file pattern attribute, @filename).
But I am not finding any relevant article or regex function that I can use for the above.
Please let me know for any clue or solution or link you have.
Upvotes: 2
Views: 13324
Reputation: 16411
When we copy data from blob to other, Data factory support using some expressions to filter the blobs in wildcard operations, like:
*
: If you want to copy all blobs from a container or folder, additionally specify wildcardFileName as *
.*.csv
: choose all the csv files from a container or folder.Start*
: copy all blobs from a container or folder which name start
with 'Start'.Ref:
It may looks like the regex expression, but very simple.
Usually, Data Factory doesn't mention about regex expression, we will consider that it's not supported.
For you purpose "the file should be a csv file and name should starts with 'D'. >the name of the file must contain a specific word.", You could using bellow Data Factory Expression in Add dynamic content
help you achieve that:
startsWith()
contains()
endsWith()
and()
For example, I just create an example pipeline with Get Metadata and a If Condition. Using bellow condition expression to filter the csv file which name start with 'D' and contains a specific word:
I prefer to use If condition, the expression is same with Filter conditon:
@and(and(startswith(activity('Get Metadata3').output.itemName,'D'),contains(activity('Get Metadata3').output.itemName,'specifcWords')),endswith(activity('Get Metadata3').output.itemName,'.csv'))
If condition is true(the csv file which name start with 'D' and contains a specific word), we could add the case active.
Upvotes: 3