> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeotap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Scenario 4: Transformation of Array Using a Custom Transformer

To transform incoming data into a list or array of objects, you can use this transformer. For example, if a field called `Product ID` is ingested into the system as follows:

`Product ID: 1234|09876|23792`

Then, although the values are separated by a pipe character, the system identifies it as a single string, which is incorrect. Moreover, storing it as a string restricts proper filtering in the downstream modules. To avoid this, store it as a list or array of strings. However, since the value is not initially in list or array format, the system converts the entire data into a single value and stores it as `ProdID(List String) = ["1234|09876|23792"]`. To correct this, use the following directives in your transformer:

#### Directives for Data Transformation

```bash Code theme={null}
find-and-replace products s/\|/”,”/g
find-and-replace products s/^/[“/g
find-and-replace products s/$/”]/g
parse-as-cdt :product ID APPEND LIST
```

Below are details of how each directive functions:

| **Directive**                          | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |                      |                                              |
| :------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | -------------------------------------------- |
| \`ProdID(List String) = \["1234        | 09876                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | 23792"]\`            | Converts the String value to list of Strings |
| `find-and-replace products s/\|/”,”/g` | Finds and replaces all occurrences of the pipe character (“                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | ”) with commas (",") |                                              |
| `find-and-replace products s/^/[“/g`   | Adds a double quotation mark (") at the beginning of each value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |                      |                                              |
| `find-and-replace products s/$/”]/g`   | Adds a double quotation mark (") at the end of each value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |                      |                                              |
| `parse-as-cdt :product ID APPEND LIST` | Reads the “Product ID” field as a list of strings<ul><li><p><strong>parse-as-cdt</strong>: This indicates that the system should interpret or parse the data according to a specified format or structure.</p></li><li><p><strong>ID</strong>: Refers to the field or attribute name, in this case, Product ID.</p></li><li><p><strong>APPEND LIST</strong>: Specifies that the data in the Product ID field should be treated as a list. This means that values within the field will be parsed and stored as values in a list structure.</p></li></ul> |                      |                                              |

As a result, the system stores the Product ID as `Product ID: ["1234", "09876", "23792"]`. This facilitates straightforward filtering of the values in downstream systems such as Audiences.
