Page 1 of 1

Splitting a Record based on a Pattern

Posted: Wed Apr 03, 2013 10:46 am
by Kalaiselva
Hi,

We have a requirement for reading stelink messages as below.

:20:ABCD122
:21:BCD3455
:32B:USD10000,00
:52B:1323467
ABC BANK
ABC OPERATIONS
NO:78, NEW TOWN
ATLANTA, NEW MEXICO 30265
:53D:1323467
BCD BANKS
BCD OPERATIONS
NO:92 FIRST SQUARE
INIDA
:50A:9612485
KJDKNUIOPA


This input record will have to be split based on the :XXX: tags. We did manage to split using Index and Field function for single line tags. Multiline tags were also split by using : as the next delimiter while capturing the record.

But now we are receiving colon ( : ) as part of the content itself. Hence breaking the code which we wrote.

Can somebody suggest me any ways to split the above mentioned record into mutiple columns based on the tag values?

Thanks,
Kalai Selvan

Posted: Wed Apr 03, 2013 3:10 pm
by ray.wurlod
Correct the arguments in your Field() function. For example everything after the second colon is given by

Code: Select all

Field(InLink.TheString, ":", 3, 999)

Posted: Thu Apr 04, 2013 12:48 am
by prasannakumarkk
Do the colon part of content should be acting as delimiter or data?

Posted: Fri Apr 05, 2013 4:23 am
by Kalaiselva
Hi Ray,

Thanks, the above code fetches data from the 2nd colon, but we need a way to stop before the next :XXX: tag starts. Thats the problem for us. We are not able to use ( : ) as the delimiter as the Data between tags are also having colon.

Thanks,
Kalai Selvan

Posted: Fri Apr 05, 2013 3:22 pm
by ray.wurlod
Is it the case that there is at most one tag per physical line? If so, test the line for beginning with a tag (or even with a colon); if not, simply accumulate the string. Form groups based on the tag and preserve only the last line in each group, probably with a Remove Duplicates stage.