FLEE Expressions for filtering

FLEE Expressions for filtering

FLEE expressions are used to define criteria for filter parameters in several COZYROC tasks and components. FLEE is a “Fast, Lightweight Expression Evaluator.” Finding documentation to help you configure a valid expression can be challenging.

The elements of Microsoft’s .NET Framework from the System.IO FileInfo class that are supported by the COZYROC LocalFilter parameter are the following: CreationTime, Directory, DirectoryName, Extension, FullName, IsReadOnly, LastAccessTime, LastWriteTime, Length, and Name. 


The elements of Microsoft’s .NET Framework from the System.IO FileInfo interface that are supported by the COZYROC RemoteFilter parameter are the following: Name, FullName, Size, ModifiedTime, and IsDirectory.

Additional elements which can be used in FLEE expressions to filter results are the following: DateTime, Now and Regex. These three elements can be used for both remote and local filters.
  1. DateTime- class/object for working with date/time methods
  1. Now - This gives a DateTime object for the current date/time
  1. Regex- regular expression class/object
Be aware that different elements are supported for the Remote Filter and the Local Filter. The elements that can be used for either the Local or the Remote filter are these elements: Name, DateTime, Now and Regex.

For more information about the classes, methods, and properties that can be used for filtering, search on the Microsoft website for the class, method, or property in the .NET documentation. For instance, if you want to work with the Date and Time, searching for “.NET DateTime” should get you to some useful information. Within that documentation, you can find different properties and methods that can be used for your specific needs (e.g. the Now property vs. the UtcNow property).

Be aware that there are differences in the expression you would use if you want files that are new within the last 24 hours vs. files that were created anytime yesterday. Likewise, the expression would be different if you were interested in when the file was created vs. when it was last modified or last written.
When setting up a FLEE expression for filtering, we recommend that you set up the expression in a variable and then use the variable option for the filter property of the task or component you are working with.

There is now a tool to help you configure a FLEE expression for some of the elements you can use in an expression. It will test your expression against some simple sample data. The following image shows the tool. The tool will appear whenever you click on the ellipses to configure a FLEE expression for a variable.



The following table contains some example FLEE expressions that have been used successfully by our customers.

  

Desired Filter Result




FLEE Expression

Filter the files where the filename starts with BR. This expression can be used for both Local Filter and Remote Filter.

Name.StartsWith("BR")

Filter files since the specified date; the date can be provided as a variable. This expression can be used only for Remote Filter.

ModifiedTime >= #01/07/2019# + ##09:00:00#


Filter .zip files that were created in the last 24 hours (this expression works if the files are in the same timezone as where the package is being executed). This expression can be used only for Local Filter.

CreationTime > Now.AddDays(-1) and Name.EndsWith(".zip")

Filter the Excel files that have the .xlsx file extension. This expression can be used for both: Local filter and Remote Filter.

Name.EndsWith(“.xlsx”)

Filter the files that are older than 5 days. This expression can be used only for the Local Filter.

LastWriteTime < Now.AddDays(-5)

Filter files with a name that starts with “Y”, has exactly 4 digits after the “Y” and is a .zip file

Regex.IsMatch(Name, "^Y\d{4}.zip$")

Filter all files that don't have the string "part" in their name. This expression can be used for both: Local Filter and Remote Filter

NOT Name.ToLower().Contains("part")

Filter the files whose name contains the Current System Date in the format yyyyMMdd. This expression can be used for both: Local Filter and Remote Filter

Name.Contains(DateTime.Today.ToString(“yyyyMMdd”))

 





























    Book a Presales Call


    Are you new to COZYROC and evaluating our solutions? 
    Book a Presales Call with us now and get 5% off SSIS+.