Monday, 10 September 2018

arcpy - Calculate Field - getting the code value but not the description


If STREETNM value are blank or _ then I want to replace them with the value of ST_DESIG. My code below returned the code value of ST_DESIG but not the description.


How can I get the description value of the ST_DESIG. For example, "Divided Major Highway - Class II" NOT 1.



enter image description here


import arcpy
Streets_Centerlines = r"G:\xStreetNew\Test.gdb\Streets_Centerlines"
expression = "replace(!STREETNM!)"
codeblock = """
def replace(STREETNM,ST_DESIG):
if STREETNM.lstrip().rstrip() == '' or STREETNM.lstrip().rstrip() == '_':
return ST_DESIG
else:
return STREETNM

"""
arcpy.CalculateField_management(Streets_Centerlines, "STREETNM", "replace(!STREETNM!,!ST_DESIG!)", "PYTHON", codeblock)


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...