← ltrim operator page · string/ltrim/ds/leading_removed_trailing_kept

Leading removed trailing kept 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

ltrim on values with spaces at both ends, a space inside and a null; the input quotes its cells, so the spaces are data.

Manual:

Whitespace removal: "Removes trailing or/and leading whitespace from a string."

Expected:

" hello " gives "hello " and " a b " gives "a b ": the leading spaces go; the trailing ones and the space inside stay (the page's rtrim examples remove the trailing ones). 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.

script.vtl ⇩

DS_r := ltrim(DS_1);

input/DS_1.csv ⇩

Id_1Me_1
1 hello
2 a b
3

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "String", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1
1hello
2a b
3

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Me_1", "type": "String", "role": "Measure"}
      ]
    }
  ]
}