This is for streamsets, I am trying to write groovy script. I have string of length 1500 chars. No delimiter. The pattern is first 4 characters are some code, next 4 characters are length of word followed by the word. Again it as 4 chars of some code and 4 chars of lenght of word followed by the word. e.g. 22010005PHONE00010002IN00780004ROSE
When you decode,it will be like
2201 - code 0005 - Length of the word PHONE - Word
0001 - code 0002 - Length of the word IN - Word
0078 - code 0004 - Length of the word ROSE - Word and so on..
I need help on groovy script to create string if the code starts with 00. Thus the final string would be INROSE.
I am trying using while loop and str:substring. Any help is very much appreciated.
Thanks
def dtx_buf = record.value['TXN_BUFFER']
def fieldid = []
def fieldlen = []
def dtx_out = []
def i = 13
def j = 0
while (i < dtx_buf.size())
{
// values = record.value['TXN_BUFFER']
fieldid[j] = str.substring(values,j,4)
output.write(record)
}
Expected result "INROSE"