Creates a new field with values taken from a mapping table.
Sourcefield: | The complete name of the field to be mapped. |
Fieldname: | The complete name of the new column to be added that will contain the mapped values. |
Mapping: | The complete name of the mapping table from which to take values. |
Missing: | What action should be taken if no mapping match is found. |
Errors: | Whether errors should trigger notifications or be ignored. |
Notify: | If ticked, a notification will be sent upon entry of a new mapping. |
Flush Table: | If ticked, the mapping table entries will be deleted prior to new mapping. Use for collecting unique values. |
If: | Here you can use a Python expression to set criteria, which, if met, will cause rows to be mapped. |
Comment: | Additional comment text that can be used to show information about the mapping entry by referencing a specific column when an error is raised or a notification is sent. Syntax is as follows:
'Hey, we found a new mapping entry for value: %s' % {column_name} |
Alternative: | String or fieldname to be used if no mapping entry is found. This can be useful as a method to create new mapping tables. |
Subtable: | Perform the transformation within a subtable, named as per this field. |
Example

Source Data: "source_1"
source_1 | metric_1 |
DE | 111 |
EN | 222 |
UK | 333 |
Mapping Table: "mapping_1"

source_1 | field_1 | metric_1 |
DE | Germany | 111 |
EN | United Kingdom | 222 |
UK | United States | 333 |
I Ain't Afraid of No Code!
[
[
"map",
{
"errors": "raise",
"missing": "ignore",
"flush_table": false,
"notify": true,
"subtable": null,
"sourcefield": "source_1",
"mapping": "mapping_1",
"fieldname": "field_1",
"alternative": null,
"if": "",
"_comment": null
}
]
]
param str errors: Ignore/raise, defaults to raise.
param str missing: What to do if no matching entry is found. Possible values are create (missing mapping entry is created), stop (stops if no mapping entry is found), create,stop. Defaults to ignore.
param boolean flush_table: When flush_table is set to true, the mapping table is flushed at the beginning. Defaults to false.
param boolean notify: Whether notifications should be sent or not.
param str subtable: Name a subtable in which output will be stored (will create subtable where necessary).
param list sourcefield: Field with values to be mapped.
param str mapping: Name of mapping table to be used.
param str fieldname: Name of field to be created.
param str alternative: String or fieldname to use if no mapping entry exists. Useful to create mapping tables.
param str if: Use an expression. Ignore rows that evaluate to false.
param list fields: Map multiple fields from value tables (used for Workspace mapping)
param str comment: A comment to add more information on the mapping entry.
Comments
0 comments
Article is closed for comments.