Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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