Search code examples
javatalend

How to process files only for a day before using Talend?


I have used tFileList in Talend to get files from a VM remote, which will be generated each day. I want to pick files only for the past hour and do the required processing. I have referred to this question in StackOverflow like below : How to process files only for the past hour using Talend? I am stuck at step of writing code in tJavaRow. The error is : # "output_row cannot be resolved to a variable" Here is my job : .

enter image description here

Here is my code in tJavaRow_1 :

((String)globalMap.get("tFileList_5_CURRENT_FILEPATH")) = input_row

Date lastModifiedDate = TalendDate.parseDate("EEE MMM dd HH:mm:ss zzz yyyy", input_row.mtime_string);

Date current_date = TalendDate.getCurrentDate();


if(TalendDate.diffDate(current_date, lastModifiedDate,"dd") <= 1) {

output_row.abs_path = input_row.abs_path;
}

Could you help me to resolve this error?

I have tried some solutions but it didn't work. Like changing output_row to tJavaRow_1 or Output because I see this schema of tJavaRow_1 .

enter image description here


Solution

  • So first there is an issue with the tJavaRow output, you linked the tFileInputDelimited and the tJavaRow with an if link it wont work

    enter image description here

    So to do what I think you want to do is change the if to a main output to a tFlowToIterate component (https://help.talend.com/r/fr-FR/7.3/orchestration/tflowtoiterate) and then link the tFileInputDelimited with a iterate flow like this :

    enter image description here

    you store in the tFlowToIterate the path and name of the file you want to read

    enter image description here

    And then use this var in the tFileInput like this :

    enter image description here