Understanding Match Types
Match Types
Definition
A large number of Library Templates have a Match Type field that allows you to select between Exact Match and Regex Match.
Exact Match - Matches to a single file, using a combination of the Folder Name and File Name.
Exact Match is like searching for a specific file on your computer by its exact name and location.
Example: Looking for jan_data.csv
inside your reports/monthly
folder.
Regex Match - Matches to multiple files, using regular expressions.
Regex Match is like using a smart search to find a bunch of files that follow a pattern.
Example: Searching for all files in reports/monthly
that end in _data.csv
(like jan_data.csv, feb_data.csv, etc.).
The Match Type selected affects the Source fields and the Destination fields differently. The names of these fields will differ based on the Template you've selected and the functionality of that Template.
Source - If you're downloading files, this will be the vendor/tool. If you're uploading files, this will be Workflow's local file system.
Destination - If you're uploading files, this will be the vendor/tool. If you're downloading files, this will be Workflow's local file system.
Functionality of the Template | Source | Destination |
---|---|---|
Download | Vendor/Tool (e.g., Dropbox) | Workflow's local file system |
Upload | Workflow's local file system | Vendor/Tool (e.g., S3 Bucket) |
Exact Match
Effects on Source
When using Exact Match, the Template will look for a file that exactly matches (case sensitive) the combination of the provided Source Folder Name and Source File Name. When the folder name and file name are combined, we correctly format the /
characters, so you don't need to worry about the difference between providing a folder as folder/structure
, /folder/structure
or folder/structure/
.
When the Source is Workflow, leaving the Folder Name blank assumes that the file you want to match to lives in the home directory. When the Source is a vendor/tool, leaving the Folder Name blank assumes that the file you want to match to lives in the root directory.
Effects on Destination
When using Exact Match, the Destination Folder Name and File name will be combined together and created exactly as you typed them.
If a Destination Folder Name is provided that doesn't already exist, it will be created.
If you leave Destination File Name empty, the original file name that you match to will be kept, stripped of the folder name.
Examples
Assume that we are downloading files from a Vendor, and our vendor has the following file structure. Click through the tabs below to see how the inputs will change the resulting file matched to.
reports/
├─ customer_data.csv
├─ external/
│ ├─ geo_data.csv
├─ monthly/
│ ├─ jan_data.csv
│ ├─ feb_data.csv
│ ├─ mar_data.csv
├─ aggregated/
│ ├─ data_yearly.csv
│ ├─ data_quarterly.csv
│ ├─ data_monthly.csv
company_data.csv
Original File Name
New File Name
No Match
Inputs
Variable Name | Value |
---|---|
Source File Name Match Type |
|
Source File Name |
|
Source Folder Name |
|
Destination Folder Name |
|
Destination File Name |
|
Result
The Template combines the folder and file name to interpret the source file as reports/monthly/jan_data.csv
. One file is found that matches. Because the Destination File Name is empty, the original file name is kept in tact.
Element | Names |
---|---|
Matched Files | reports/monthly/jan_data.csv |
Downloaded Files | jan_data.csv |
Regex Match
Effects on Source
When using Regex Match, the Template will first filter down to the folder provided under Source Folder Name. Next, it will then pull in every file that exists under your filter and its subfolders. Then, it will compare the names of these files to the regex provided under Source File Name. All matching file names are then looped through for downloading/uploading.
When the Source is Workflow, leaving the Folder Name blank will cause Workflow to search for all matches in the home directory and its subdirectories. When the Source is a vendor/tool, leaving the Folder Name blank will cause Workflow to search for all the matches in the root directory and its subdirectories.
Technically, all files names are a combination of their folder name and file name.
We look at the full file path, not just the file name. So reports/data.csv
could be matched even if your pattern only seems to target the file name.
Technically, all files names are a combination of their folder name and file name. So a file named data.csv
in a folder named reports
is seen as reports/data.csv
for the sake matching with regex. This can result in your regex matching to a file because of its folder name.
Effects on Destination
If you provide a Destination File Name when Regex Match is used, and more than one file is matched to, we enumerate the files by adding _#
to the end of the file name before the file extension.
What does enumerate mean? We’ll add numbers at the end to keep the files separate—just like naming photos vacation_1.jpg, vacation_2.jpg, etc., to avoid replacing the previous one
This prevents each file from being uploaded/downloaded with the same name, which would result in a single file being continuously overwritten.
For example, if you provided a Destination File Name of report.csv
and your regex finds multiple matches, the files will be uploaded/downloaded as report_1.csv
, report_2.csv
, etc.
If you leave Destination File Name empty, the original file names that you match to will be kept, stripped of the folder name.
Examples
Assume that we are downloading files from a Vendor, and our vendor has the following file structure.
reports/
├─ customer_data.csv
├─ external/
│ ├─ geo_data.csv
├─ monthly/
│ ├─ jan_data.csv
│ ├─ feb_data.csv
│ ├─ mar_data.csv
├─ aggregated/
│ ├─ data_yearly.csv
│ ├─ data_quarterly.csv
│ ├─ data_monthly.csv
company_data.csv
Fully Filtered Match
Variable Name | Value |
---|---|
Source File Name Match Type |
|
Source File Name |
|
Source Folder Name |
|
Destination File Name |
|
Result
The Template filters down to the folder of reports/monthly
. In this folder, it finds 3 files that match the regex. The original file names are kept in tact.
Element | Names |
---|---|
Matched Files | reports/monthly/jan_data.csv |
Downloaded Files | jan_data.csv |
Sub-Folder Match
Inputs
Variable Name | Value |
---|---|
Source File Name Match Type |
|
Source File Name |
|
Source Folder Name |
|
Destination File Name |
|
Result
The Template filters down to the folder of reports
. In this folder, it finds a folder, monthly
that matches the regex - so it includes all of its files. Additionally, it finds a file in the subfolder aggregated
. Because the Destination File Name is empty, the files retain their original names.
Element | Names |
---|---|
Matched Files | reports/aggregated/data_monthly.csv |
Downloaded Files | data_monthly.csv |
Enumerated Destination Files
Inputs
Variable Name | Value |
---|---|
Source File Name Match Type |
|
Source File Name |
|
Source Folder Name |
|
Destination File Name |
|
Result
The Template does not filter down at all. Across all folders and subfolders, it finds 6 files that match the regex. It then proceeds to name all of them data_#.csv
, due to enumeration logic.
Element | Names |
---|---|
Matched Files | reports/customer_data.csv |
Downloaded Files | data_1.csv |
Non-Enumerated Destination Files
Inputs
Variable Name | Value |
---|---|
Source File Name Match Type |
|
Source File Name |
|
Source Folder Name |
|
Destination File Name |
|
Result
The Template does not filter down at all. Across all folders and subfolders, it finds 1 file that matches the regex. It then proceeds to name it data.csv
Element | Names |
---|---|
Matched Files | reports/monthly/jan_data.csv |
Downloaded Files | data.csv |