[resolved] Please help me with RUNif condition for TfileRowcount

Six Stars

[resolved] Please help me with RUNif condition for TfileRowcount

HI Team ,
I need check whether file is empty or not , for that I m using TfileRowcount  to get total number of records what condition do I  need to write in runif . If number of records zero it should file is empty or it should display totalnumber of records ...................
thanks!

Accepted Solutions
Community Manager

Re: [resolved] Please help me with RUNif condition for TfileRowcount

Hi
If file exists,  you can use a tFileRowCount to populate the number of lines, there is a global variable called ((Integer)globalMap.get("tFileRowCount_1_COUNT")) that stores the result. eg:
tFileExist--runIf--tFileRowCount--oncomponentok--tFixedFlowInput--main--tLogRow
on tFixedFlowInput, generate the number of lines, define one column let's say it as "nb_line", set its value as:
((Integer)globalMap.get("tFileRowCount_1_COUNT"))
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

View solution in original post


All Replies
Community Manager

Re: [resolved] Please help me with RUNif condition for TfileRowcount

You can do this by following the image I have attached to this post. The file has a parameter called "number of lines". This can seen circled in red on the left. Drag this over to your RunIf link component condition. Then set the greater than/less than logic you require. You don't actually need the row count component.

Six Stars

Re: [resolved] Please help me with RUNif condition for TfileRowcount

Thanks rhall, its working but
But my requirement if the file is empty it job should abort with message " No records" if not it should give me total number of records .......for my auditing purpose ..  above solution is not giving me total number of records could you please help me with how I can fetch total number of records ..
Thanks
Mohini
Community Manager

Re: [resolved] Please help me with RUNif condition for TfileRowcount

Hi
If file exists,  you can use a tFileRowCount to populate the number of lines, there is a global variable called ((Integer)globalMap.get("tFileRowCount_1_COUNT")) that stores the result. eg:
tFileExist--runIf--tFileRowCount--oncomponentok--tFixedFlowInput--main--tLogRow
on tFixedFlowInput, generate the number of lines, define one column let's say it as "nb_line", set its value as:
((Integer)globalMap.get("tFileRowCount_1_COUNT"))
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

View solution in original post

Six Stars

Re: [resolved] Please help me with RUNif condition for TfileRowcount

Many thanks Shong its working .............
Smiley Happy
MOhini

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 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog