Data lookups
I lookup <name> in the "<filepath>" file where "<predicate>"
Looks up a named data value in a CSV or JSON file based on a predicate function and binds its value to the same name in the global scope.
I lookup <name> in the "<filepath>" file where "<predicate>"
Where
<name>the name of the data to look up the value of and the name to bind it to<filepath>the path to the CSV or JSON file to look up<predicate>is the javascript predicate expression that will returntruewhen a match is found for a record orfalseotherwise (can be in DocString position) Data fields can be referenced in the predicate using either:${data.record.NAME}(since v3.47.0)${csv.record.NAME}for CSV data or${json.record.NAME}for JSON data (for prior versions)
The data value contained in the first record that satisifes the given predicate will be bound to the global scope. Otherwise if no records match, then no value will be bound.
Examples
CSV Lookup
Given the CSV file: lookup/StateCodes.csv
Code,Name
ACT,Australian Capital Territory
NSW,New South Wales
NT,Northern Territory
QLD,Queensland
SA,South Australia
TAS,Tasmania
VIC,Victoria
WA,Western Australia
The following will bind "Western Australia" in the last record to Name in the global scope
When I lookup Name in the "lookup/StateCodes.csv" file where "'${data.record.Code}' == 'WA'"
Then Name should be "Western Australia"
JSON Lookup
Since v3.47.0
Given the JSON file: lookup/StateCodes.json
[
{ "Code": "ACT", "Name": "Australian Capital Territory" },
{ "Code": "NSW", "Name": "New South Wales" },
{ "Code": "NT", "Name": "Northern Territory" },
{ "Code": "QLD", "Name": "Queensland" },
{ "Code": "SA", "Name": "South Australia" },
{ "Code": "TAS", "Name": "Tasmania" },
{ "Code": "VIC", "Name": "Victoria" },
{ "Code": "WA", "Name": "Western Australia" }
]
The following will bind "Western Australia" in the last record to Name in the global scope
When I lookup Name in the "lookup/StateCodes.json" file where "'${data.record.Code}' == 'WA'"
Then Name should be "Western Australia"
I lookup <name> in <filepathRef file> where "<predicate>"
Looks up a named data value in a referenced CSV or JSON file based on a predicate function and binds its value to the same name in the global scope.
I lookup <name> in <filepathRef file> where "<predicate>"
Where
<name>the name of the data to look up the value of and the name to bind it to<filepathRef file>is the name of the binding containing the path of the CSV or JSON file to look up<predicate>is the javascript predicate expression that will returntruewhen a match is found for a record orfalseotherwise (can be in DocString position) Data fields can be referenced in the predicate using either:${data.record.NAME}(since v3.47.0)${csv.record.NAME}for CSV data or${json.record.NAME}for JSON data (for prior versions)
The data value contained in the first record that satisifes the given predicate will be bound to the global scope. Otherwise if no records match, then no value will be bound.
Examples
CSV Lookup
Given the CSV file: lookup/StateCodes.csv
Code,Name
ACT,Australian Capital Territory
NSW,New South Wales
NT,Northern Territory
QLD,Queensland
SA,South Australia
TAS,Tasmania
VIC,Victoria
WA,Western Australia
The following will bind "QLD" in the 4th record to Code in the global scope
Given mapping file is "lookup/StateCodes.csv"
When I lookup Code in mapping file where "'${data.record.Name}' == 'Queensland'"
Then Code should be "QLD"
JSON Lookup
Since v3.47.0
Given the JSON file: lookup/StateCodes.json
[
{ "Code": "ACT", "Name": "Australian Capital Territory" },
{ "Code": "NSW", "Name": "New South Wales" },
{ "Code": "NT", "Name": "Northern Territory" },
{ "Code": "QLD", "Name": "Queensland" },
{ "Code": "SA", "Name": "South Australia" },
{ "Code": "TAS", "Name": "Tasmania" },
{ "Code": "VIC", "Name": "Victoria" },
{ "Code": "WA", "Name": "Western Australia" }
]
The following will bind "QLD" in the 4th record to Code in the global scope
Given mapping file is "lookup/StateCodes.json"
When I lookup Code in mapping file where "'${data.record.Name}' == 'Queensland'"
Then Code should be "QLD"
I lookup <dataName> in the "<filepath>" file as <name> where "<predicate>"
Looks up a named data value in a CSV or JSON file based on a predicate function and binds its value to a given name in the global scope.
I lookup <dataName> in the "<filepath>" file as <name> where "<predicate>"
Where
<dataName>the name of the data to look up the value of<filepath>the path to the CSV or JSON file to look up<name>the name to bind the looked up value to in the global scope<predicate>is the javascript predicate expression that will returntruewhen a match is found for a record orfalseotherwise (can be in DocString position) Data fields can be referenced in the predicate using either:${data.record.NAME}(since v3.47.0)${csv.record.NAME}for CSV data or${json.record.NAME}for JSON data (for prior versions)
The data value contained in the first record that satisifes the given predicate will be bound to the global scope. Otherwise if no records match, then no value will be bound.
Examples
CSV Lookup
Given the CSV file: lookup/StateCodes.csv
Code,Name
ACT,Australian Capital Territory
NSW,New South Wales
NT,Northern Territory
QLD,Queensland
SA,South Australia
TAS,Tasmania
VIC,Victoria
WA,Western Australia
The following will bind "New South Wales" in the 2nd record to state name in the global scope
When I lookup Name in the "lookup/StateCodes.csv" file as state name where "'${data.record.Code}' == 'NSW'"
Then state name should be "New South Wales"
JSON Lookup
Since v3.47.0
Given the JSON file: lookup/StateCodes.json
[
{ "Code": "ACT", "Name": "Australian Capital Territory" },
{ "Code": "NSW", "Name": "New South Wales" },
{ "Code": "NT", "Name": "Northern Territory" },
{ "Code": "QLD", "Name": "Queensland" },
{ "Code": "SA", "Name": "South Australia" },
{ "Code": "TAS", "Name": "Tasmania" },
{ "Code": "VIC", "Name": "Victoria" },
{ "Code": "WA", "Name": "Western Australia" }
]
The following will bind "New South Wales" in the 2nd record to state name in the global scope
When I lookup Name in the "lookup/StateCodes.json" file as state name where "'${data.record.Code}' == 'NSW'"
Then state name should be "New South Wales"
I lookup <dataName> in <filepathRef file> as <name> where "<predicate>"
Looks up a named column value in a referenced CSV or JSON file based on a predicate function and binds its value to a given name in the global scope.
I lookup <dataName> in <filepathRef file> as <name> where "<predicate>"
Where
<dataName>the name of the data in the CSV or JSON file to look up the value of<filepathRef file>is the name of the binding containing the path of the CSV or JSON file to look up<name>the name to bind the looked up value to in the global scope<predicate>is the javascript predicate expression that will returntruewhen a match is found for a record orfalseotherwise (can be in DocString position) Data fields can be referenced in the predicate using either:${data.record.NAME}(since v3.47.0)${csv.record.NAME}for CSV data or${json.record.NAME}for JSON data (for prior versions)
The data value contained in the first record that satisifes the given predicate will be bound to the global scope. Otherwise if no records match, then no value will be bound.
Examples
CSV Lookup
Given the CSV file: lookup/StateCodes.csv
Code,Name
ACT,Australian Capital Territory
NSW,New South Wales
NT,Northern Territory
QLD,Queensland
SA,South Australia
TAS,Tasmania
VIC,Victoria
WA,Western Australia
The following will bind "VIC" in the 7th record to state code in the global scope
Given mapping file is "lookup/StateCodes.csv"
When I lookup Code in mapping file as state code where "'${data.record.Name}' == 'Victoria'"
Then state code should be "VIC"
JSON Lookup
Since v3.47.0
Given the JSON file: lookup/StateCodes.json
[
{ "Code": "ACT", "Name": "Australian Capital Territory" },
{ "Code": "NSW", "Name": "New South Wales" },
{ "Code": "NT", "Name": "Northern Territory" },
{ "Code": "QLD", "Name": "Queensland" },
{ "Code": "SA", "Name": "South Australia" },
{ "Code": "TAS", "Name": "Tasmania" },
{ "Code": "VIC", "Name": "Victoria" },
{ "Code": "WA", "Name": "Western Australia" }
]
The following will bind "VIC" in the 7th record to state code in the global scope
Given mapping file is "lookup/StateCodes.json"
When I lookup Code in mapping file as state code where "'${data.record.Name}' == 'Victoria'"
Then state code should be "VIC"