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
-
1Could you show how you execute the function?Bera– Bera2017年11月16日 14:07:28 +00:00Commented Nov 16, 2017 at 14:07
1 Answer 1
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 !!
-
Thanks you for the reply, I tried what you mentioned with no luck. I also completely changed the names. ArcMap spits out an Error "Python syntax error: Parsing error SyntaxError: invalid sytax (line 1)LandArch– LandArch2017年11月16日 14:43:07 +00:00Commented Nov 16, 2017 at 14:43
-
@LandArch: Try again. I missed the colon ( : ) on the def... lineBera– Bera2017年11月16日 14:48:07 +00:00Commented Nov 16, 2017 at 14:48
Explore related questions
See similar questions with these tags.