replace-values-in-columns
replace-values-in-columns
adaptor replaces all instances of a pattern in one or more columns in a datatable.
The replacement values can be written to the original columns or new columns.
Inputs
data
Type: datatable
Required: Yes
The datatable containing values to be replaced.
columns
Type: dictionary
Required: Yes
A dictionary of existing column names with names of new columns, where the dictionary keys are the names of existing columns, and the dictionary values are the names of the columns to which the replacement values are written. If a dictionary value is left blank, the replacement values are written to the original column.
pattern
Type: text
Required: Yes
The text or regular expression to be replaced. The pattern is treated as a regular expression if it begins and ends with /
(e.g., /.*/
).
replacement
Type: text
Required: No
The text that replaces all instances of the pattern
. If unspecified, matches will be replaced with blank text. If a regular expression was used as a pattern, capture groups can be included as $1
, $2
, etc.
Outputs
data
Type: datatable
A datatable with replacement values written to the original columns or new columns.
Examples
Example 1: Default behaviour.
Inputs:
data
:
1
GB
United Kingdom
2
TR
Turkey
3
US
United States
4
IND
India
columns
:
code
pattern
: GB
replacement
: UK
Outputs:
list
:
1
UK
United Kingdom
2
TR
Turkey
3
US
United States
4
IND
India
-> Replaced the value GB
in the existing code
column with the value UK
.
Last updated