Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
RA6
Creator
Creator

Data validation - Empty file Handling

Hello,

 

I want to know how to implement some validation before processing a file.

 

In fact, i have a file (csv) have contain header and i want to check if the file is empty(excluding the header) then process to tmap else die.

 

Can you advice please?

 

Thank you.

 

Best regards,

asadasing

 

 

 

 

 

 

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

@asadasing i think you can use tFileRowCount component.

View solution in original post

3 Replies
Anonymous
Not applicable

Hello,

In Talend, you can use tFileProperties to get the file properties, there is a field called size that populate the file size, if it is 0, means the file is empty. According to your description, a job design for example looks like:
tFileFlist--iterate--tFileProperties--tJavaRow--runIf_1-->normal processing flow
                                                                  --runIf_2--->another processing if the file is empty
on tJavaRow, check the file if it is empty and put the result to a global variable, for example:

if(input_row.size==0){ globalMap.put("isEmpty", true); }else{ globalMap.put("isEmpty", false); }

set the condition of runIf_1 as:
!(Boolean)globalMap.get("isEmpty")

set the condition of runIf_2 as:
(Boolean)globalMap.get("isEmpty")

Let us know if it is OK with you.

Best regards

Sabrina

 

RA6
Creator
Creator
Author

Hello,

Thank you for your response, in tfileproperties, it does the size calculation in bytes.
Hence, i cannot check if file = 0 ; I have tried to check the flow with an empty file and it returns 2 and now my empty contain header, i guess the value will change.

Can you advice please on how i can proceed?
Anonymous
Not applicable

@asadasing i think you can use tFileRowCount component.