Page 1 of 1

How to solve below scenario using loop in tfm or otherway

Posted: Fri Dec 29, 2017 12:43 pm
by seanirs
My data is like below in one column coming from a file. There is customer information and every customer can have one meter or many meters and every meter will have atleast one reading or many. every meter may or may not have a meter statement. if meter statement is absent then pad 100 spaces. below is the sample data. there is only one column in the complete file and no other columns and no other way to tie to those meters and readings to the parent customer. just follow the order in sequence.

Source_data---(This is column name)
CUSTOMER 15
METER 8
METERStatement 1
READING 1
METER 56
Meterstatement 17
Reading 5
Reading 6
Reading 7
CUSTOMER 38
METER 24
METERStatement 1
READING 51
CUSTOMER 77
METER 38
READING 9

I want the output data to be like below in one column

CUSTOMER 15 METER 8 METERStatement 1 READING 1
CUSTOMER 15 METER 56 Meterstatement 17 Reading 5
CUSTOMER 15 METER 56 Meterstatement 17 Reading 6
CUSTOMER 15 METER 56 Meterstatement 17 Reading 7
CUSTOMER 38 METER 24 Meterstatement 1 Reading 51
CUSTOMER 77 METER 38 'pad 100 spaces' Reading 9

I am trying to solve by reading transformer looping documentation but could not figure out an actual solution. anything helps. thank you all.

Posted: Fri Dec 29, 2017 1:18 pm
by Mike
I don't see any need for transformer looping. It looks to me like you can do everything with stage variables and output constraints.

Mike

Posted: Fri Dec 29, 2017 1:26 pm
by seanirs
could you please elaborate for me...

Posted: Fri Dec 29, 2017 1:39 pm
by seanirs
There is customer information and every customer can have one meter or many meters and every meter will have atleast one reading or many. every meter may or may not have a meter statement. if meter statement is absent then pad 100 spaces. below is the sample data. there is only one column in the complete file and no other columns and no other way to tie to those meters and readings to the parent customer. just follow the order in sequence

Posted: Fri Dec 29, 2017 8:28 pm
by ray.wurlod
I, too, would resolve this purely using stage variables. You need an output link constraint expression to determine when to generate an output row (e.g. when the input is a READING row).