Splitting a String into Multiple Rows
【Question】
I use Version: Luna Service Release 1 (4.4.1)
Build id: 20140925-1800
Could you tell me, for each line, how to cut the line in terms of space and put each value on another line
My table:
ID ANOMALIES
3903 B1 D1 CAT1
3904 D7 D2 B1 CAD4
I would like to:
ID ANOMALIES
3903 B1
3903 D1
3903 CAT1
3904 D7
3904 B1
3904 D2
3904 CAD4
I am a beginner and I have a lot of difficulties with the declaration and array use, I don’t understand when and how to fill an array. Could you help me? Thank You, have a nice day
Pierre
【Answer】
You can use a stored procedure to cut each field value into multiple rows, but the code will be complicated. It’s simple to do this in SPL:
A |
|
1 |
$select * from data |
2 |
=A1.news(ANOMALIES.split(" ");ID:ID,~:ANOMALIES) |
A1: Read the original data;
A2: Cut each of the ANOMALIES field values by space to generate a sequence and union them into a new table sequence.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_SPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL