gregczajko

python code in modelbuilder using Calculate Value

Discussion created by gregczajko on Dec 11, 2012
Hi,
I'm attempting to check for the existence of a shapefile if it does not exist, an alternate dummy shapefile is returned in its place.  I'm using ArcGIS 10.1 Modelbuilder and specifically the Calculate Value tool, here is the code:

Expression:
chkSouceSHP(%YIP Delivery from York (Shapefile Folder):%\%YIPData_Name%.shp)


Code Block:
def chkSouceSHP(SourceSHP):
  if os.path.isfile(SourceSHP):
    return SourceSHP
  else:
    return "M:\GIS\Data\YIP\Process\BlankMetadata.shp"


Data Type:
Shapefile


This code errors out with:

ERROR 000539: SyntaxError: invalid syntax (<expression>, line 1)
Item not found in this collection.
Failed to execute (Calculate Value).


Any help or hints for where I can find help would be greatly appreciated.
I've read:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000v8000000

This error appears to be coming from Python, and since I'm quite new to it I'm hoping someone on here who has more experience will be able to figure this out.

thanks,
Greg
Ontario, Canada

Outcomes