Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Recognize and ignore empty files in a folder

Cremo
7 - Meteor

Hi Alteryx Community,

 

I am new to Alteryx, and I would first like to thank you for such a great community that has allowed me to solve most of the issues and tasks. Now I am facing a problem and I would need your help.

 

In my flow, I need to read a list of files in a folder and process them one by one. To accomplish this, I get the list of files through the Directory Tool and use them as input to a batch macro that does the main work. So far so good. However, the files are the output of other processes over which I have no control, and this is where the problem arises: it can happen that some of these files are empty, they exist but do not contain any kind of data. As a result, these files fall in the list of files read by the directory tool, but when they are processed they result in error (obviously) because the input tool does not read any data.

 

The question I would like to ask is this: is there a way to solve this problem, perhaps by recognizing empty files before passing them as input to the batch macro?

The best solution I have thought of so far is to check the file size in the directory tool and filter out those with size = 0 (I attach a picture as an example). However, I noticed that the empty files in the example folder either have size = 0 or = 1 byte, so for now the filter is set to exclude 0 or 1 byte files.
This does not seem to me to be a very robust method, considering that the files are produced periodically and I would not want there to be empty files with sizes of a few bytes in the future that bypass the filter causing the error again.

Do you have any advice on this? Thank you in advance

 

Capture.PNG

 

3 REPLIES 3
dYoast
11 - Bolide

You might consider using the Count Records tool in your macro.  If there are 0 records, bypass the file.

DataNath
17 - Castor

Just a suggestion as I can't think of too many options other than upping your size threshold, but again this isn't 100% fool proof I'd imagine:

 

I'm guessing you have a dynamic input further downstream? After that, you could perhaps add a 'Field Info' tool and use that to condition another filter? Maybe filtering on the count of fields (if all empty files will only have 1 for example) or even if the file has x amount of fields below a certain size?

Cremo
7 - Meteor

Thank you for your answers, they are surely useful. My problem is that my batch macro starts with an input tool, which fails immediately once it tries to read an empty file (attached example), leading to the error "no fields found". So everything I include after that is not reached.

 

Cremo_1-1652711301006.png

 

Labels