MarTech
MarTech

Reputation: 115

How to create empty file if file does not exist

I want to retrieve files from a folder, while testing the existence of each of these files, and generate empty files if the file in question does not exist without displaying an error message. I am using the tFileExist component, while following the documentation on the official Talend website: https://help.talend.com/reader/Fa7iBFy6fRgEvdHqg85dYQ/QFh2k28YZ6scCHDV85SCkA. But the thing is that even if the file exists, it overwrites it and replaces it with an empty file.

Upvotes: 0

Views: 1210

Answers (2)

Houssem_B
Houssem_B

Reputation: 1

you can do it as below

tFileInputExcel (contains the list of all your file names) --> tmap --> tFlowToIterate --> tFileExist (you put the the directory path / the variable created in tFlowToIterate that contains the file name) ------run if trigger ( you put the condition of non existance) ---> tFileTouch (put the directory path / the variable created in tFlowToIterate that contains the file name)

in my case I put tFileCopy Instead of tFiletouch

enter image description here

Upvotes: 0

NickW
NickW

Reputation: 9788

I don't believe that example from Talend is correct: the description doesn't match what is being built.

The "On Subjob Ok" branch is going to run as long as the tFileExist component runs ok, regardless of the result of that component. You would need to add a 2nd "if" branch to the tFileExist component (without the negation in the logic of the other if branch) and add the appropriate components to those 2 "if" branches. The "On Subjob Ok" branch can be deleted.

Upvotes: 1

Related Questions