Start Free Trial

Alteryx Designer Desktop Discussions

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

Alert a user if file input is corrupt or a different format of file?

vdix
7 - Meteor

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?

2 REPLIES 2
mceleavey
17 - Castor
17 - Castor

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/...

 

Here is a method to do that. 

You can also trigger an email using Events on error.

 

I hope this helps,

 

M



Bulien

grazitti_sapna
17 - Castor

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 Alteryx
from zipfile import ZipFile

 

#################################
# read in data from input anchor as a pandas dataframe
# (after running the workflow)
df = Alteryx.read("#1")


#################################
# create a new column
df['Valid'] = 0


#################################
# loop through the rows and validate the zip files
for 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 anchors
Alteryx.write(df, 1)

 

Sapna Gupta
Labels
Top Solution Authors