display message in console when no rows in output file

One Star

display message in console when no rows in output file

Hello,
I would wand to know how I can control the number of rows of a file. When there is no row it displays in the console "There is no row" and if there are rows I want to display "there is (number of rows)rows"
regards,
JOLLYJOHN
One Star

Re: display message in console when no rows in output file

Hello,

well in the place of the tLogRow we can use a tJava to display the value of global variable from components with the commande System.out.println();

for example like this code :

System.out.println(((Integer)globalMap.get("tRowGenerator_1_NB_LINE")));

Best Regards

Jeremie
One Star

Re: display message in console when no rows in output file

you can use a tJava component, and connect it to your database component via a "On Subjob Ok" link
in tJava you could use something like this:
if(((Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")).equals(0)) {
System.out.println("There are no rows.");
}
else {
System.out.println("There are " + ((Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")) + " rows.");
}

or, to make it grammatically correct, and easier to read:
System.out.println("");
if( ((Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")).equals(0) ) {
System.out.println("There are 0 rows.");
}
else if( ((Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")).equals(1) ) {
System.out.println("There is " + ((Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")) + "row.");
}
else {
System.out.println("There are " + ((Integer)globalMap.get("tFileOutputExcel_1_NB_LINE")) + " rows.");
}
System.out.println("");
One Star

Re: display message in console when no rows in output file

or you could use If links, like in the first attached picture
Note: the "System.out.println("***tJava_#***");" lines were just to show you which tJava_# the summary line printed from, and wouldn't be necessary in your solution
If (order:1)
((Integer)globalMap.get("tFileInputDelimited_1_NB_LINE")).equals(0)

tJava_1
System.out.println("");
System.out.println("***tJava_1***");
System.out.println("There are no rows.");
System.out.println("");

If (order:2)
((Integer)globalMap.get("tFileInputDelimited_1_NB_LINE")).equals(1)

tJava_2
System.out.println("");
System.out.println("***tJava_2***");
System.out.println("There is " + ((Integer)globalMap.get("tFileInputDelimited_1_NB_LINE")) + "row.");
System.out.println("");

If (order:3)
((Integer)globalMap.get("tFileInputDelimited_1_NB_LINE")) > 1

tJava_3
System.out.println("");
System.out.println("***tJava_3***");
System.out.println("There are " + ((Integer)globalMap.get("tFileInputDelimited_1_NB_LINE")) + " rows.");
System.out.println("");

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now