I have a Feature Class in a Geodatabase with an field for pipe diameter. I also have a shapefile with a field for diameter. The shapefile is from field verification work that verified a variety of pipe characteristics. I have joined the shapefile to the Feature Class in ArcMap, see the image below. I would like to recalculate using Field Calculator and the Python Parser the first diameter field with that information in the second diameter field, any null values would keep the original data in the first diameter field. Through some research I have hodgepodged the following script that fails upon execution when using the Filed Calculator. ArcMap spits out an Error:
Python syntax error: Parsing error SyntaxError: invalid syntax (line 1)
def IgnoreNull (GravitySewer.Diameter, assets.Diameter)
if assets.Diameter is None:
return GravitySewer.Diameter
else:
return assets.Diameter
Answer
You need to change bottom line in field calculator to:
IgnoreNull(!GravitySewer.Diameter!, !assets.Diameter!)
You could also have a problem with the dots in the function variable names. Try changing them in the codeblock to:
def IgnoreNull (GravitySewer_Diameter, assets_Diameter):
if assets_Diameter is None:
return GravitySewer_Diameter
else:
return assets_Diameter
You can name them whatever you want. It is when you call the function you need the real field names enclosed in !!
No comments:
Post a Comment