Meter records tMap

Five Stars

Meter records tMap

Hi guys!!

 

I'm a beginner in Talend.  I would appreciate your help with the next topic:

 

I'm creating a .csv from a DB. I'm using tmap to tranfer the data from the DB to the .csv, doing some changes. My problem is with a new field I want to create.

 

Some different registers can have the same ID, so in my .csv I can get something like this:

0001|.....

0001|....

0001|....

 

What I'm trying to do is to create a new field (column in the .csv) that works like a meter, to know how many times the ID is repeated   --> example:

0001|1

0001|2

0001|3

 

 

I have try it in the tMap, codding the field function... but I just achive to compare this table row with other table rows, but for the same record, not for every one....

 

Any solution is welcome, even if it has to be developed outside the tmap.

 

thanks in advance

Kind regards,

Jorge

 

 

 


Accepted Solutions
Nine Stars

Re: Meter records tMap

@jchamorro - you could use Numeric.sequence to generate a sequence number for your input. 

Something like this - 

tFixedFlowInput-2.JPG

tMap configuration - 

tMap-Seq3.JPG

 

Edit: For multiple input just have a tSortRow between your input component and tMap

tRowGenerator-1.JPGtRowGenerator-2.JPG


All Replies
Nine Stars

Re: Meter records tMap

@jchamorro - you could use Numeric.sequence to generate a sequence number for your input. 

Something like this - 

tFixedFlowInput-2.JPG

tMap configuration - 

tMap-Seq3.JPG

 

Edit: For multiple input just have a tSortRow between your input component and tMap

tRowGenerator-1.JPGtRowGenerator-2.JPG

Five Stars

Re: Meter records tMap

Thanks @iamabhishek for your quick answer.

 

I have tried what you proposed (I attack a screenshot) , but I got something like that:

 

0001|1.....

0002|2.....

0002|3.....

0003|4....

0003|5....

0003|6...

0004|7...

 

And what I need is :

 

0001|1.....

0002|1.....

0002|2.....

0003|1....

0003|2....

0003|3...

0004|1...

 

I need to restart the meter or the sequence every time the Id is different.

 

Thank you again.

Kind regards

Jorge

 

Nine Stars

Re: Meter records tMap

I strongly believe you have missed a tSortRow between your input and tMap, see the edit posted.
Five Stars

Re: Meter records tMap

Thank you very much @iamabhishek 

 

Your idea worked pretty good

 

Kind regards,

Jorge