← rtrim operator page · string/rtrim/comp/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

rtrim of a component inside calc, on values that end with a space; the input quotes them, so the space is data.

Manual:

Whitespace removal, Example 2, output verbatim: "Removes trailing or/and leading whitespace from a string."

Expected:

the new measure Me_2 is hello and hi, without the trailing space; Me_1 keeps "hello " and "hi ".

script.vtl ⇩

DS_r := DS_1[ calc Me_2:= rtrim(Me_1)];

input/DS_1.csv ⇩

Id_1Id_2Me_1
1Ahello
2Bhi

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Id_2Me_1Me_2
1Ahello hello
2Bhi hi

expected/DS_r.json ⇩

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