Premium Feature — This feature is available in the Professional, Professional Plus, and Enterprise Editions.
Learn more or
contact LabKey
File Watchers let administrators set up the monitoring of directories on the file system and perform specific actions when desired files appear. This topic covers using file patterns to define which files are 'desired' by the reloader. Use file patterns in conjuction with the target container path to take action on specific files.
No File Pattern Provided / Default File Pattern
If no FilePattern is supplied, the default pattern is used:
(^\D*).(?:tsv|txt|xls|xlsx)
This pattern matches only file names that contain letters and special characters (for example: Dataset_A.tsv). File names which include digits (for example: Dataset_1.tsv) are not matched, and their data will not be loaded.
If you want to target datasets that have digits in their names, use a
"name capture group" as the FilePattern. See below for details.
Under the default file pattern, the following reloading behavior will occur:
File Name | File Watcher Behavior |
---|
DemographicsA.tsv | File matched, data loaded into dataset DemographicsA. |
DemographicsB.tsv | File matched, data loaded into dataset DemographicsB. |
Demographics1.tsv | No file match, data will not be loaded. |
Demographics2.tsv | No file match, data will not be loaded. |
User defined pattern
You can use any regex pattern to select source files for reloading. For example, suppose you have the following third source files:
FooStudy_Demographics.tsv
FooStudy_LabResults.tsv
BarStudy_Demographics.tsv
The regex file pattern...
will result in the following behavior...
File Name | File Watcher Behavior |
---|
FooStudy_Demographics.tsv | File matched, data loaded into dataset FooStudy_Demographics. |
FooStudy_LabResults.tsv | File matched, data loaded into dataset FooStudy_LabResults. |
BarStudy_Demographics.tsv | No file match, data will not be loaded. |
"Name Capture Group" pattern
This type of file pattern extracts names or ID's from the source file name and targets an existing dataset of the same name or id. For example, suppose you have a source file with the following name:
dataset_Demographics_.xls
The following file pattern extracts the value <name> from the file name, in this case the string "Demographics" that occurs between the underscore characters, and loads data into an existing dataset with the same name "Demographics".
dataset_(?<name>.+)_.(xlsx|tsv|xls)
Note that you can use the technique above to target datasets that include numbers in their names. For example, using the pattern above, the following behavior will result.
File Name | File Watcher Behavior |
---|
dataset_Demographics_.tsv | File matched, data loaded into dataset Demographics. |
datasetDemographics.tsv | No file match, data will not be loaded. |
dataset_LabResults1_.tsv | File matched, data loaded into dataset LabResults1. |
dataset_LabResults2_.tsv | File matched, data loaded into dataset LabResults2. |
To target a dataset by its dataset id, rather than its name, then use the following regex, where <id> refers to the dataset id. Note that you can determine a dataset's id by navigating to your study's
Manage tab, and clicking
Manage Datasets. The table of existing datasets shows the id for each dataset in the first column.
dataset_(?<id>.+)_.(xlsx|tsv|xls)
Related Topics