ForEachCSVListItem
Executes an action against each row in a CSV list.
Syntax
ForEachCSVListItem( CSVList, KeywordList, ActionName, ListSeparator, RowSeparator );
Parameters
Parameter Name | Type | Description | Optional? | Default Value |
---|---|---|---|---|
CSVList | String | The CSV list to use. | No | n/a |
KeywordList | String | A CSV list of keywords matching the variables that will store the values from each row of CSVList. This must include as many variable keywords as there are values in the list, and the order in which the keywords appear determines which value is passed to each one; for example, the first keyword will contain the first value of each row, and so on in that fashion. | No | n/a |
ActionName | String | The keyword of the action to perform. | No | n/a |
ListSeparator | String | The single character that separates values in CSVList. | Yes | , |
RowSeparator | String | The single character that separates rows in CSVList. | Yes | | |
Output
If at least one row in the CSV matches the specified data, the function will return True; otherwise, it will return False.
Use Case
A CSV list is used to monitor the inventory of an online store, with one product listed per row. Whenever a product's stock level is low, the procurement department must be alerted so they can order more of that item.
Each row in the CSV contains three details about the product: its name, its category and the number of items left in stock. A data sample from this CSV might read as follows:
"Red Sofa, Home, 2|Curtains, Home, 8|Parasol, Garden, 12"
To make sure a stock level check is performed for each item stored in CatalogueData, the following expression is used:
ForEachCSVListItem( CatalogueData, "ProductName, ProductCategory, StockLevel", "StockCheck" );
For each row in CatalogueData, the row's individual values are passed to specified variables and the StockCheck action is called. For example, this action might send an email to your company's stores to alert them of the need to order new stock.