CSV Reader (handling if the file is not found)

Hello,

I have a question again and hope you can help me. :slight_smile:

I would like to have some kind of IF branching after or before the CSV reader.

Basically I would like to choose between 2 branches.

1st branch: IF file found load the data
2nd branch: IF file not found create an empty csv file.

image

Or you have a completely different idea to solve this case?

I am curious if you have ideas.
Thanks in advance.

BR

Andre

Hi @AndreP -

Take a look at the example workflow below, which does something similar to what you want, just using XML files… It takes a list of XML files and loops over them, trying to access each one. It uses the Try/Catch nodes to decide what happens: if the read is successful, continue on - but if it fails, then generate an empty table instead.

Maybe you can adapt this for your purposes?

Hi @AndreP , as @ScottF mentioned, Try/Catch would do it. In fact, it’s the only way that I know of to accomplish that - maybe there are other ways that I am not aware of.

Basically, it would look like this:
image

If the csv file was read successfully - be it file exists, and data is good, then it will feed the Catch Errors node. However, if the csv file was not read successfully - file does not exist, or cannot open file, or can’t read the file, then the Catch Errors node will be fed through the 2nd port, basically coming from the Table Creator node where you can create your empty csv

2 Likes

Hi @bruno29a and @ScottF ,

works! Thank you so much!

BR

Andre

2 Likes