← substr operator page · string/substr/comp_start_len/manual_ex_3
pandas ✅ · DuckDB ✅
substr(Me_2, 1, 5) inside calc, where the result replaces the measure Me_2.
Sub-string extraction, Example 3, output verbatim: "The substring starts from the startth character of the input string and has a number of characters equal to the length parameter."
Me_2 is mediu, short and "this " (with its trailing space); Me_1 is unchanged.
DS_r:= DS_1 [ calc Me_2:= substr ( Me_2 , 1 , 5 ) ];
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 1 | A | hello world | medium size text |
| 1 | B | abcdefghilmno | short text |
| 2 | A | pqrstuvwxyz | this is a long description |
{
"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}
]
}
]
}
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 1 | A | hello world | mediu |
| 1 | B | abcdefghilmno | short |
| 2 | A | pqrstuvwxyz | this |
{
"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"}
]
}
]
}