One Star

operation with tmap or taggregate, calculation

Hi
could anybody help?
I have a file like this:
ID F. No.1 No.2 No.3
A 3 1 1
B 2 1 1
C 4 1 1 1
A 3 1 1
A 2 1 1

in the end I want to have this: Rows which have the same ID and F. should go together
ID F. No.1 No.2 No.3
A 3 1 1 1
B 2 1 1
C 4 1 1 1
A 2 1 1
Could this be solved with t-map or taggreaterow ?
4 REPLIES
Employee

Re: operation with tmap or taggregate, calculation

In the aggregation, which operation do you want to perform? because for ID-A, f-3, No.2 should be 2 if you sum. So, do you want a "exists" function ?
Community Manager

Re: operation with tmap or taggregate, calculation

Hello Ham
Does the value of 'No1..NO3' always be empty or '1'? if so ,you can use the max function, here is a scenario:
input file:
a;3;1;1;
b;2;;1;1
c;4;1;1;1
a;3;;1;1
a;2;;1;1
result;
Starting job forum5928 at 21:57 23/03/2009.
ID: c|F: 4|NO1: 1|NO2: 1|NO3: 1
ID: a|F: 3|NO1: 1|NO2: 1|NO3: 1
ID: a|F: 2|NO1: |NO2: 1|NO3: 1
ID: b|F: 2|NO1: |NO2: 1|NO3: 1
Job forum5928 ended at 21:57 23/03/2009.

Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: operation with tmap or taggregate, calculation

An existing-function sounds good.
I tried with taggregate. But the result is false. It counts the number of equal IDs, but not the number of No.1, No.2.... for each ID with it F.
Could you explain taggregate to me?
Employee

Re: operation with tmap or taggregate, calculation

An existing-function sounds good.

btlink
Could you explain taggregate to me?

For a description of tAggregateRow, please check the documentation user guide.
Here comes an example of to perform your job, without the "exists" aggregation function, the trick is to perform a sum, and then reduce to undef or 0. The output of my job is:
Starting job topic5928 at 15:03 24/03/2009.
.--------------------------.
| tLogRow_1 |
+----+---+-----+-----+-----+
| id | f | no1 | no2 | no3 |
+----+---+-----+-----+-----+
| A | 3 | 1 | 1 | 1 |
| A | 2 | | 1 | 1 |
| C | 4 | 1 | 1 | 1 |
| B | 2 | | 1 | 1 |
'----+---+-----+-----+-----'
===
execution time: 15 milliseconds
===
Job topic5928 ended at 15:03 24/03/2009.