Transformation Types¶
Overview¶
- Transformations can be chained
- SDM doesn’t handle calculations (Ex: we don’t calculate the TVA from the prices columns)
Types of Transformations¶
| Transformation | Parameters | Description | Example |
|---|---|---|---|
| Capitalize | which (start, sentences, word, all, none) |
Capitalizes specific parts of a text based on the which parameter. |
start: First character only sentences: First character. Of each! Sentence (.?!) word: First Character Of Each Word all: ALL CHARACTERS none: all lowercase |
mode (strict, loose) |
Defines how strict or loose the capitalization should be. | Strict: The Sdm App Is Awesome Loose: The SDM App Is Awesome |
|
| trim_whitespaces | multiple |
Removes spaces at the beginning and end of a text string. If multiple is True, reduces multiple space characters between words to a single space character. ℹ️ trim_whitespaces preserves line breaks (\n) in your text. It only removes leading/trailing whitespace from each individual line. |
Input: " Hello World " Output: "Hello World" With multiple is True: Input: " I am John" Output: "IamJohn" |
| regex | pattern (string) |
Defines what needs to be transformed | |
substitution (string) |
Specifies the substitution text to replace the matched pattern. | ||
force |
True/False | If true: SDM empties the value If false but the value doesn’t match, nothing happens | |
| pad | pad_character, pad_length |
Adds characters to the left or right of the string to reach a specific length. | Example: EAN exported from Excel like this 0003542147089. The first 3 zeros will not be imported, resulting in an invalid EAN. Setting pad_character to 0 and pad_length to the EAN length will prepend with the missing 0s. |
| multiply | factor (number) |
Multiplies the input numeric value by the given factor. | Input: 5, Factor: 10 Output: 50 |
1. Capitalize¶
Adjusts the capitalization of text values.
Parameters:
name:capitalize-
which: Determines what to capitalize. Options:"start": Capitalizes only the first character."sentences": Capitalizes the first character of each sentence (default)."words": Capitalizes the first character of each word."all": Converts the entire string to uppercase."none": Converts the entire string to lowercase.-
mode: Determines the strictness of capitalization. Options: -
"strict": Uses Python's built-incapitalize()method. "loose": Only capitalizes the first character, leaving the rest unchanged (default).
Example:
> "hello world. how are you?" # (which="sentences", mode="loose")
# Output: "Hello world. How are you?"
2. Trim Whitespaces¶
Removes excess whitespace from the value.
Function: trim_whitespaces(value, multiple=False)
Parameters:
name:trim_whitespacemultiple: IfTrue, replaces all multiple spaces within the string. IfFalseonly the extra spaces at the start and end of the string are replaced.
Example:
3. Regex¶
Applies a regular expression substitution to the value.
Parameters:
name:regexpattern: The regex pattern to match.substitution: The string to replace matched patterns with.flags: List of regex flags to use. Options:"ascii","multiline","ignorecase","dotall". Uses Python flags behind the scenes.force: IfTrue, returnsNonewhen the pattern doesn't match.
Example:
> "Hello123World" # (pattern=r"\\\\d+", substitution="", flags=["ignorecase"])
# Output: "HelloWorld"
Warning
Important note about escaping¶
When specifying regex patterns in the configuration JSON, backslashes need to be double-escaped
This means:
\d(regex digit) becomes\\din the configuration\w(regex word character) becomes\\w- A literal backslash becomes
\\ - Capture groups substitutions also need to be escaped twice so they become
\\1,\\2, etc.
Examples:
// Simple digits removal:
{
"transformations": [
{
"name": "regex",
"pattern": "\\d+",
"substitution": "",
"flags": ["ignorecase"],
"force": false
}
]
}
// Input: `"Hello123World"` → Output: `"HelloWorld"`
// Extracting part of a number sequence:
{
"transformations": [
{
"name": "regex",
"pattern": "^(\\d{8})(\\d{2})$",
"substitution": "\\1",
"flags": ["ignorecase"],
"force": false
}
]
}
// Input: `"1234567890"` → Output: `"12345678"`
// Removing break lines:
{
"transformations": [
{
"name": "regex",
"flags": [
"multiline"
],
"force": false,
"pattern": "\\r?\\n",
"substitution": ""
}
]
}
// Input: `"Hello\nWorld"` → Output: `"HelloWorld"`
4. Pad¶
Pads the string value to a specified length.
Parameters:
name:padfill: The character to use for padding.direction: Where to add padding. Options:"left"or"right".length: The desired total length of the string after padding.
Example:
5. Multiply¶
Multiplies a numeric value by a specified factor. This is useful for unit conversions (e.g., converting meters to millimeters) or applying fixed coefficients.
Parameters:
name:multiplyfactor: The number by which the input value will be multiplied. Can be an integer or a decimal (float).
Example:
Usage Notes¶
- Transformations run on all the fields sent to the step. During the step, when the user modifies a field in the UI, the transformation will only run on the fields that have been modified after the form has been submitted.
- Transformations are applied in the order they are specified in the configuration.