CSVListRemoveRow

Attempts to locate a specific row of data in a CSV list. If the row is found, the function will delete the first instance of it; otherwise, nothing is deleted.

Syntax

CSVListRemoveRow( CSVList, KeywordList, ListSeparator, RowSeparator );

Parameters

Parameter Name Type Description Optional? Default Value
CSVList String The CSV list from which the row should be removed. No n/a
KeywordList String A CSV list of values to search for and delete from 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

If the specified data exists in the CSV, the function will return the original list with the row removed. If the specified data could not be found in the CSV list, it will be returned unchanged.

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 two rows is shown below:

"HV13796,P0001,Floral Dress,S,Blue,35.00|HV13796,P0002,Jeans,M,Maroon,45.00"

If the customer wants to remove an item from their basket, they will need to completely remove the corresponding row from the UserBasket. This is done using the following expression:

UserBasket:= CSVListRemoveRow(UserBasket, UnwantedBasketItem);

The UnwantedBasketItem keyword refers to a specific row of product date to be removed:

"HV13796,P0001,Floral Dress,S,Blue,35.00"

After the expression completes, the contents of UserBasket read as follows:

"HV13796,P0002,Jeans,M,Maroon,45.00"