Combinator Masks
The concatenate and chain masks are special in that they can combine multiple masks together.
This is especially useful in combination with other masks such as
typecast (typecast
).
- Concatenate
Combines the output of multiple mask operations together - Chain
Chains multiple mask operations, passing the output of one to the next
Concatenate (concat
)
Concatenates the outputs of multiple masks together into a single string.
Parameters
masks
(required): A list of masks (or dictionary mapping keys to masks) which will be evaluated and have their outputs concatenated into a single value. The original column value is provided as the input to each mask.glue
(optional): If provided, this string will be inserted between the output of each concatenated mask. Defaults to an empty string. Useful for separating values with spaces or commas.
Example
This example generates a full name by concatenating a user’s name
with
the fixed value ‘Smith’.
version: '1.0'
tasks:
- type: mask_table
table: employees
key: id
rules:
- column: name
masks:
- type: concat
glue: " "
masks:
- type: from_column
source_column: name
- type: from_fixed
value: "Smith"
Show result
Before | After |
|
|
---|
Chain (chain
)
Chains other masks together in series. This mask is only useful in combination with concat
,
in the case where multiple masking operations need to be performed on one part of a concatenated mask.
Parameters
masks
(required): A list of masks (or dictionary mapping keys to masks) that will be applied in sequence to the input value.
Example
This example selects a random name from the DataMasque_firstNames_mixed.csv file, transforms it to uppercase, and then concatenates ‘Smith’ onto it to generate a random full name.
version: '1.0'
tasks:
- type: mask_table
table: employees
key: id
rules:
- column: name
masks:
- type: concat
glue: ' '
masks:
- type: chain
masks:
- type: from_file
seed_column: firstname-mixed
seed_file: DataMasque_firstNames_mixed.csv
- type: transform_case
transform: uppercase
- type: from_fixed
value: 'Smith'
Show result
Before | After |
|
|
---|