← substr operator page · string/substr/ds_start/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

substr(DS_1, 7): every value of both measures from the 7th character to its end.

Manual:

Sub-string extraction, Example 1, output verbatim: "If length is omitted or overcomes the length of the input string, the substring ends at the end of the input string."

Expected:

Me_1 is world, ghilmno and vwxyz; Me_2 is " size text" (with its leading space), text and s a long description.

script.vtl ⇩

DS_r:= substr ( DS_1 , 7 );

input/DS_1.csv ⇩

Id_1Id_2Me_1Me_2
1Ahello worldmedium size text
1Babcdefghilmnoshort text
2Apqrstuvwxyzthis is a long description

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},
        {"name": "Me_2", "type": "String", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Me_1Me_2
1Aworld size text
1Bghilmnotext
2Avwxyzs a long description

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"}
      ]
    }
  ]
}