CSVListAddRow
Appends a single row of CSV data to a list. If the string is initially empty, the result is a new CSV containing that single row of data.
Syntax
CSVListAddRow( CSVList, KeywordList, ListSeparator, RowSeparator );
Parameters
Parameter Name | Type | Description | Optional? | Default Value |
---|---|---|---|---|
CSVList | String | The CSV list to which the new row should be added. | No | n/a |
KeywordList | String | A CSV list of values to add to CSVList. | 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
The function will return the original CSV list containing the new row appended to the end.
Use Case
An online clothes store provides a facility that lets customers add items to a virtual shopping basket. Each customer has their own basket, which will be emptied whenever they end their current session. Because the data is local and temporary, it is stored as CSV using the keyword UserBasket.
Each row of the basket CSV lists the customer's unique ID together with the chosen product's reference number, description, size, colour and price. A sample customer basket containing one row is shown below:
"HV13796,P0001,Floral Dress,S,Blue,35.00"
When a customer wants to add a new item to their basket, they click a button that triggers the following expression:
UserBasket:= CSVListAddRow(UserBasket, NewBasketItem);
The NewBasketItem keyword refers to a new row of product data to be added to the UserBasket CSV:
"HV13796,P0002,Jeans,M,Maroon,45.00"
After the expression completes, the contents of UserBasket read as follows:
"HV13796,P0001,Floral Dress,S,Blue,35.00|HV13796,P0002,Jeans,M,Maroon,45.00|"