← ltrim operator page · string/ltrim/comp/leading_removed_trailing_kept
pandas ✅ · DuckDB ✅
ltrim of a component inside calc, on values with spaces at both ends, a space inside and a null; the input quotes its cells, so the spaces are data.
Whitespace removal: "Removes trailing or/and leading whitespace from a string."
the new measure Me_2 is "hello " for " hello " and "a b " for " a b ": the leading spaces go; the trailing ones and the space inside stay (the page's rtrim examples remove the trailing ones); Me_1 is kept. A null operand gives a null result: "most of the scalar operations (arithmetic, logical, and others) return null when any of their arguments is null" (User Manual), as the manual's length and instr examples show.
DS_r := DS_1[calc Me_2 := ltrim(Me_1)];
| Id_1 | Me_1 |
|---|---|
| 1 | hello |
| 2 | a b |
| 3 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "String", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | hello | hello |
| 2 | a b | a b |
| 3 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "String", "role": "Measure"},
{"name": "Me_2", "type": "String", "role": "Measure"}
]
}
]
}