[resolved] Count number of rows in a file and sent the total in an email

One Star

[resolved] Count number of rows in a file and sent the total in an email

Hello,
I am trying to count the number of rows in a file and send that total in an email.
So far my approach has been to use a tAggregateRow on the tFileOutput to get the count.  Is there a way using tSetGlobalVar to get the count value from the tAggretateRow and insert that into the “Message” section of the TSendMail?
My layout is as follows tFileOutput -> tAggregateRow -> tSetGlobalVar -> tSendMail
If this layout will work should the Value under tSetGlobaVar be set to something like “tAggregateRow”
Thanks

Accepted Solutions
Nine Stars

Re: [resolved] Count number of rows in a file and sent the total in an email

Wouldn't it be easier to use the tFileRowCount component?
You can display the result via tJava:
System.out.println(globalMap.get("tFileRowCount_1_COUNT"));
https://help.talend.com/search/all?query=tFileRowCount&content-lang=en

All Replies
Nine Stars

Re: [resolved] Count number of rows in a file and sent the total in an email

Wouldn't it be easier to use the tFileRowCount component?
You can display the result via tJava:
System.out.println(globalMap.get("tFileRowCount_1_COUNT"));
https://help.talend.com/search/all?query=tFileRowCount&content-lang=en
One Star

Re: [resolved] Count number of rows in a file and sent the total in an email

Hi,
You don't need to use the global variable. You can put in the tSendMail the value straight from tAggregateRow/tFileRowCount using following format: output_name.output_column_name (for example row1.count_rows).
If the returned count value is Integer you need to convert it to string String.valueOf(row1.count_rows).