How to loop through and find the count of line items in Talend

Six Stars

How to loop through and find the count of line items in Talend

Hello Folks,

 

I have a field like below in my input file consists of multiple fp line items and some other time CHG_CLASS will contain only one fp line items. 

CHG_CLASS

 fp

 fp

 mrc

 mrc

 

After I load the data base I would want to check this and depending upon this single fp line items I will execute one logic and if input file has multiple fp line items I will execute one other update logic using tMySQLRow.

 

Thanks in advance!

 

Basically I want to look through and check in my input file column CHG_CLASS do I have one single fp line items or more than one fp line items or not.

 

Regards,

Deepak

 

 

Forteen Stars TRF
Forteen Stars

Re: How to loop through and find the count of line items in Talend

Duplicate question isn't it?


TRF
Sixteen Stars

Re: How to loop through and find the count of line items in Talend

You can achieve this (if I understand you correctly), by adding a tMap and adding a count column. In the count column use this code....

routines.Numeric.sequence(row1.CHG_CLASS, 1, 1)

What this will do is start a sequence for every CHG_CLASS value that goes through the tMap. So if you data comes through in this order, the "count" column will hold what is shown below....

CHG_CLASS | Count
fp|1
dr|1
fp|2
dw|1
test|1
fp|3
dr|2

 

I've assumed some values as you can see. 

The last fp value that is returned will have the max count. This doesn't completely solve your issue because you need to get the value, but I think you can probably find a way of doing this and I do not know the rest of your requirement.

 

Sixteen Stars

Re: How to loop through and find the count of line items in Talend

Hi @Deepak1, did this answer your question?