Our process reads a CSV file…at times, the CSV file it empty (which is fine), but the process faults because it does not find anything in the file.
When this happens, we would like to have the process end, mark as successful
thank you in advance
Our process reads a CSV file…at times, the CSV file it empty (which is fine), but the process faults because it does not find anything in the file.
When this happens, we would like to have the process end, mark as successful
thank you in advance
You have two options.
Surround your process with a Try Catch. If the process faults anywhere, the exception that is generated will be caught, and the process will end successfully.
After you read the csv file and before you process the content, just check if the output is empty, and conditionally process it. Otherwise, do nothing and the process will end.
What exactly is faulting? The Read CSV activity? Or later activities fault because there are no rows in the datatable?
You need to be more specific in providing info here so we can better assist.
It is faulting because there are no rows in the csv.
“It is faulting”
Faults come from specific activities. Which activity is faulting?
@Burdette_Brown Please check the workflow. It will ends the process gracefully though the data not present in csv
Example.zip (2.8 KB)
Output
Except ANY exception reading the file will be interpreted by your code as “no data in csv” - for example if the user cannot access the file due to missing permissions, it’ll return “no data in csv.”
A better way to do this would be to have a System.ArgumentNullException catch. That is the specific exception thrown if there is no data in the file. Then your System.Exception block can be used to catch everything else.
An even better way would be to use Get File Info and check the length of the file. If it’s 0, then don’t read the file, just return “no data.”
Even a text file with only a single character in it will be read by Read CSV. It’s ONLY files that are literally empty that throw an exception.