Chech delimited file if it's empty

Highlighted
Six Stars

Chech delimited file if it's empty

How I can check if a delimited file is empty except the headline?

 

Let say this is an csv output but nothing has been appended:

 

Column1|Column2

 

 

If I use tfileExist the condition is always true because the file exists because of the header.

Thanks for any advice.


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: Chech delimited file if it's empty

tFileRowCount with the option "Ignore empty rows" is a solution.

If row count is > 1 (((Integer)globalMap.get("tFileRowCount_1_COUNT")) > 1) then the file contains the header line + at least 1 non empty line.


TRF

All Replies
Employee

Re: Chech delimited file if it's empty

Hi,

 

    The most easy way is to read the file and send the output to a tAggregateRow component. Create an output column which will calculate the total count of records. If the value is not zero, it means you have data else its empty file.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Fifteen Stars TRF
Fifteen Stars

Re: Chech delimited file if it's empty

tFileRowCount with the option "Ignore empty rows" is a solution.

If row count is > 1 (((Integer)globalMap.get("tFileRowCount_1_COUNT")) > 1) then the file contains the header line + at least 1 non empty line.


TRF

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

Downloads and Trials

Test drive Talend's enterprise products.

Downloads