How can I create an error to let the user know if the value input is of a different file type or if the file corrupt? How can i go about achieving this?
Hi @vdix ,
these are two different things. If you want to check if a file does not exist, or is of a different type, the Directory tool can be used to return a list of files in a location. If, say, you are expecting a file per day, then you can determine the date from the metadata, and determine if the file exists. If it does not, but there is a new file in a .csv format for that day, then you can trigger an alerts using the email tool.
If you want to send a warning on error, have a look at this discussion:
https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Send-Error-Emails-on-Workflow-Failure/td-p/787424
Here is a method to do that.
You can also trigger an email using Events on error.
I hope this helps,
M
Hi @vdix, you can try using the python tool for this. Here is one example,
The input can be a list with a path to the zip files called [DownloadPath]. The Python tool checks if each file is a valid zip file and gives 1 or 0 answer in a new [Valid] column.
################################## List all non-standard packages to be imported by your# script here (only missing packages will be installed)from ayx import Package#Package.installPackages(['pandas','numpy'])
#################################from ayx import Alteryxfrom zipfile import ZipFile
################################## read in data from input anchor as a pandas dataframe# (after running the workflow)df = Alteryx.read("#1")
################################## create a new columndf['Valid'] = 0
################################## loop through the rows and validate the zip filesfor ind in df.index:
file = df['DownloadPath'][ind].replace('\\','/')
try: test = ZipFile(file) df['Valid'][ind] = 1 except: df['Valid'][ind] = 0
################################## and then send it to one of the output anchorsAlteryx.write(df, 1)