Automatically populate a mapping table

This reference explains how to create an enrichment script that will automatically populate a mapping table with data from a data extract.

Introduction

Apply a mapping table to a datastream to find source values in the collected data, map target values onto these source values, and use the target values to populate a new column in the data extract.

mapping tables contain the following two columns:

  • MATCH - Populate this column with the source values contained in a data extract (for example, DE).

  • VALUE - Populate this column with target values to map on to the source values in the MATCH column (for example, Germany).

Use an enrichment script to update a mapping table with the latest data from a data extract. Once updated, all datastreams using this mapping table will have the latest values during the enrichment process.

Prerequisites

Before you complete the procedure in this guide, perform all of the following actions:

  • Create an empty mapping table. For more information, see Creating and applying mapping tables.

  • Find the name of the columns in the data extract that contain the data used to populate the mapping table.

Procedure

To create an enrichment script that automatically populates a mapping table with data from a datastream, follow these steps:

  1. Select the workspace you work with in Adverity and then, in the platform navigation menu, click Enrichments.

  1. In the top right corner, click + Create Enrichment.

  2. Click Custom Script.

  3. (Optional) To assign the enrichment to individual datastreams of your choice, follow these steps:

    1. In the Assign to section, select Individual datastreams.

    2. In the drop-down menu, select the datastreams to assign the enrichment to them.

  4. (Optional) To assign the enrichment to all existing and new datastreams that belong to Datastream Types of your choice, follow these steps:

    1. In the Assign to section, select Datastreams Types.

    2. In the drop-down menu, select the Datastream Types to assign the enrichment to all datastreams that belong to these types.

    3. (Optional) In the Do not assign to these individual datastreams drop-down menu, select the individual datastreams that belong to the Datastream Types that you have selected, but you do not want to assign the enrichment to them.

  1. Click Next.

  1. In Select Instruction, enter and select map.

  2. In Sourcefield, enter the name of the column in the data extract that contains the source values to populate the MATCH column of the mapping table.

  3. In Fieldname, enter the value DeleteMe. This is a mandatory field but it is not required for this mapping enrichment script. This value is to be removed in the same script using a separate instruction. How to set up this separate instruction is covered in more detail below.

  4. In Mapping, enter the name of the mapping table to be populated.

  5. In Missing, select create.

  6. In Errors, select ignore.

  7. Select the Flush Table checkbox to delete all previous entries in the mapping table each time the enrichment script is run. This step ensures the mapping table is populated with only the latest data.

  8. In Alternative, enter the name of the column in the data extract that contains the target values used to populate the VALUE column of the mapping table.

  9. Below the map instruction, click Add Instruction.

  10. In Select Instruction, enter and select cutout.

  11. In Fields, click Add.

  12. In the drop-down field, select String and enter DeleteMe into the field next to it.

  1. Click Next.

  1. (Optional) In Enrichment name, rename the enrichment.

  2. Click Create +.

As a result, the enrichment script is created and can be applied to the relevant datastream to update the mapping table. For more information on how to apply an enrichment script, see Applying a mapping enrichment to a datastream.