talendtalend-mdm

How to count the number of rows in a flow in Talend?


I am trying to get the number of rows in a flow in Talend. I have a subjob that looks like this: enter image description here How can I get the number of rows from this flow (where the red arrow is) and write that value to another document or store it in a variable. I know I can use a variable like this in the tMap:

tMap

But that still doesn't help me, because I just need the total number of rows. How can I do this in Talend?


Solution

  • Talend output components have a global variable called NB_LINE which you can use to get the number of rows written to the component's file or table.
    In your case you can use tFileOutputExcel's variable:
    (Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")
    Note that this is an "after" variable which is available after the file has been written, so you can get it using an OnComponentOk or OnSubjobOk.