Page 1 of 1

Question on Sequential file stage parsing

Posted: Fri May 20, 2011 4:15 am
by srinivas.nettalam
The input record in a seq. file is ABCDEFGH .can we get the output as
A
B
C
D
E
F
G
H? One of my colleagues asked me this and I replied that we can't.Probably it is one of the interview questions but is it really possible?
If the record length is always same then we can pivot(horizontal) ,but the record length is unknown in this case.

Posted: Fri May 20, 2011 6:26 am
by debrujr
Without actually trying it could you not disregard the thought of delimeters in your sequential file and set a field length of 1? Like I said I haven't tried it, but I would think some tinkering with that would allow it. If not then some use of the Restructure operators would allow it somehow. I have to say that it is possible.

Posted: Tue May 31, 2011 3:06 pm
by xch2005
Is the length fixed ie. (A...H) or dynamic?

Posted: Tue May 31, 2011 5:18 pm
by ray.wurlod
srinivas.nettalam wrote:If the record length is always same then we can pivot(horizontal) ,but the record length is unknown in this case.
One solution involves a BASIC Transformer stage or a server job.
Convert(@TM,@FM,Fold(InLink.TheString, "1L")) and write to a sequential file in which field delimiter is none and metadata consists of one Char(1) column.

Another solution involves using a parallel routine. That does much the same (inserts a line terminator between each pair of characters). You could achieve the same with, for example, a sed script invoked through an External Filter stage.