Extractkv Transform

Extractkv Transform

Overview
The Extractkv transform extracts key-value pairs from a source column and creates a new column containing those key-value pairs formatted as a map. The source column must have a data type of string. The data in the resulting column will conform to the following format:
{“key1”:”value1”,”key2”:”value2”…}
 



Usage


The following table explains how to use parameters with the Extractkv transform:
Parameter Modifier Usage
Column Argument: Column in your dataset. Required. Use this parameter to select the column in your dataset that contains key-value pairs that you want to extract into a new column.
Key pattern Argument: Pattern written using any of the allowable text-matching clauses. Required. Use this parameter to specify the pattern of the keys in the source column. You can define the pattern using string literals, regular expressions, or Trifacta selection rules.
Separator between key and value Argument: Pattern written using any of the allowable text-matching clauses. Required. Use this parameter to specify the character used to separate the key and value of each key-value pair.
Delimiter between each pair Argument: Pattern written using any of the allowable text-matching clauses. Required. Use this parameter to specify the pattern of the delimiter that separates key-value pairs in the source column.
New column name Argument: Literal string. Optional. Allows the user to name the new column created by the Extractkv transform. Default is to name the new column as column1 (or the lowest available integer).

Example
A user wants to extract the data in a column into a new column containing a map of key-value pairs.

Source column:


The following Builder step uses the Extractkv transform to create a new column that contains the key-value pairs from the source column formatted as a map:
Choose a transformation Column Key pattern Separator between key and value Delimiter between each pair New column name
extractkv column1 `{alpha}+` `=` `\;` column1


Result column:





keywords: extractkv, key-value pairs, transform