Page 1 of 1

Flattening a multi record type text file

Posted: Sat Jun 02, 2012 7:35 pm
by hsahay
Hi

I need to flatten a mainframe like text file. There are 3 record types:
Header (1st byte is an 'A')
Segment (1st byte is a '$')
Detail (1st byte is numeric)

Input
Axxxxxxx
$yyyyyyy
01detaaa
02detbbb
03detccc
Azzzzzzz
$jjjjjjj
01detddd

Desired Output
Axxxxxxx$yyyyyyy01detaaa
Axxxxxxx$yyyyyyy02detbbb
Axxxxxxx$yyyyyyy03detccc
Azzzzzzz$jjjjjjj01detddd

Any Suggestions?

Thanks,
Joan

Posted: Sun Jun 03, 2012 1:20 am
by ray.wurlod
First byte or first character?

Either way, I'd read this as a single VarChar field and do the parsing and flattening in a Transformer stage. Use stage variables to preserve, and detect changes in, the header and segment records.