This is good example of how we can Eliminate bottlenecks with IguanaX by building a custom file reader component which has a simple interface for a unique purpose rather than using a general purpose no code solution - see The problem with no-code solutions.
Here’s a scenario:
A large lab needs to have a file reading component which can feed files from different customers based on the prefix of the file, i.e. some files start with JJ99, others XYZ etc. depending on the source.
Let’s do it!
Expand | |||
---|---|---|---|
| |||
This component generates some test files to make it easier to learn how to make a custom file reader. You can useCreate component +FROM URL to import the component. Copy paste the URL from here:
|
Expand | ||
---|---|---|
| ||
See Refer to Customizing components to see how it's done if you have not done this before. |
Expand | ||
---|---|---|
| ||
To simplify the tutorial we have set these up a ClientList with the filename prefix Ids. Click on the config.json and you should see: See Custom Fields to understand how this was created. |
Expand | |||||
---|---|---|---|---|---|
| |||||
Navigate to MatchRules.lua in the Project Tree. This is the function we need to alter:
The file reader component is deliberately simple and uses /wiki/spaces/IXB/pages/3181903910 to make it more obvious how to modify the code to meet new needs. We need this function to return true when the matching criteria are met. |
Expand | |||||
---|---|---|---|---|---|
| |||||
Change the matching to add in two lines so we can see the filenames we need to filter on.
These are the concepts we have used:
|
Expand | |||||
---|---|---|---|---|---|
| |||||
To simplify the tutorial we have set these up already. Click on the config.json and you should see: See Custom Fields to understand how this was created. | |||||
Expand | |||||
| |||||
Now we need Create a second function, APPidList() to extract the fields ClientList prefixes from the custom configuration. So fields and update MatchFile() to call APPidList(). You can replace the contents of the MatchRules.lua file with this new contentcode:
Concepts used:
|
Expand | |||||
---|---|---|---|---|---|
| So we add one line
| ||||
We can quickly do this by adding one line to AppidList( ) after line 2:
You should see something like: Concepts used: |
Expand | |||||
---|---|---|---|---|---|
| |||||
So now we make Create a third function, APPmatchPrefix() to determine if the file name matches filename matches the prefix. You can copy the code below:
And we’ll call it as part of the MatchFile routine. You will need to type in the line as part of Match file to call APPmatchPrefix:See the screenshot below and add a line to MatchFile() to call and invoke the AppmatchPrefix() function. Concepts used: |
Expand | |||||
---|---|---|---|---|---|
| |||||
Let’s modify the code to go through the entire list of prefixes:
And this is what you should see: Concepts used:
|
...