Five Stars

How to check top row.

Hello. I want to check top row from csv data .

 

source data is like ;

 companyID | companyName| oppotunityID

      1 |    AAAA  |  12345

      1 |    AAAA  |  6789

      2 |    BBBB  |  11111

      2 |    BBBB  |  12346

      3 |    CC  |  22222

 

and requirement output like this;

flag |companyID | companyName| oppotunityID

  *  |    1 |    AAAA  |  12345

      |   1 |    AAAA  |  6789

  *  |    2 |    BBBB  |  11111

      |    2 |    BBBB  |  12346

  *   |    3 |    CC  |  22222

 

I want to mark the first line of data for each companyID.

How can we compare the data before and after a line?

 

Thank you.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Forteen Stars TRF
Forteen Stars

Re: How to check top row.

@MartinD, as explained by @mkami input and output are csv files.

Use a tMap with the input connected to your input file and the output connected to the output file and each with the corresponding schema.
Declare 3 locale variables (in the middle of the tMap):
- currentId: connected to input flow companyID
- flag: enter the expression
(Var.previousId == null || !Var.previousId.equals(Var.currentId)) ? "*" : ""
- previousId: enter the expression
Var.currentId

As expressions are executed in the order they are defined, you can easily imagine the result.
Now connect output fields to the corresponding one from the input flow and connect the flag field to the variable Var.flag

TRF
3 REPLIES
Four Stars

Re: How to check top row.

Hi mkami,

I'm using this SQL statement:

"select companyID, max(oppotunityID)
from company
group by companyID"

Mark in tMap  and in tDBOutput "Action on data" Update row with new flag.

 

MartinD

Forteen Stars TRF
Forteen Stars

Re: How to check top row.

@MartinD, as explained by @mkami input and output are csv files.

Use a tMap with the input connected to your input file and the output connected to the output file and each with the corresponding schema.
Declare 3 locale variables (in the middle of the tMap):
- currentId: connected to input flow companyID
- flag: enter the expression
(Var.previousId == null || !Var.previousId.equals(Var.currentId)) ? "*" : ""
- previousId: enter the expression
Var.currentId

As expressions are executed in the order they are defined, you can easily imagine the result.
Now connect output fields to the corresponding one from the input flow and connect the flag field to the variable Var.flag

TRF
Five Stars

Re: How to check top row.

@TRF

Exactly! Thank you ~ Smiley Happy I can get correctly data using tMap.

 

@MartinD

also, thanks for your comment Smiley Happy