I'm building a script tool that processes shapefiles ( GPS data collected on weekly basis). The tool is set up to take an input for each shapefile ( in this case Sewer, Storm, Sign). On some days, data for one of these assests may not be collected, so there will be no dataset to provide to the tool. I thought O.K., i'll just set the input parameter to optional, and if no dataset is provided, it'll just continue on to the next dataset. Wrong answer, play again. Is it possible to make this work?
Here's a snippet of the code.
#SEWER#
sewer = arcpy.GetParameterAsText(0)
arcpy.AddField_management(sewer, "UID", "TEXT", 10, "", "", "", "NON_NULLABLE", "", "")
arcpy.AddField_management(sewer, "Phot1_Link", "TEXT", 240, "", "", "", "NON_NULLABLE", "", "")
#Calculate UID field
fieldName = "UID"
expression = "id_gen()"
codeblock = """def id_gen(size = 9, chars = string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for x in range (size))"""
arcpy.CalculateField_management(sewer, fieldName, expression, "PYTHON", codeblock)