4

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)

enter image description here

def IgnoreNull (GravitySewer.Diameter, assets.Diameter)
 if assets.Diameter is None:
 return GravitySewer.Diameter
 else:
 return assets.Diameter

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Nov 16, 2017 at 14:01
1
  • 1
    Could you show how you execute the function? Commented Nov 16, 2017 at 14:07

1 Answer 1

4

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 !!

answered Nov 16, 2017 at 14:15
2
  • 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) Commented Nov 16, 2017 at 14:43
  • @LandArch: Try again. I missed the colon ( : ) on the def... line Commented Nov 16, 2017 at 14:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.