AnsweredAssumed Answered

Issue with calculate field in python

Question asked by rbasaria on Apr 14, 2020
Latest reply on Apr 14, 2020 by rbasaria

Hello all! I am working on a python script tool, and seem to have run into an issue. 

 

The tool basically takes 2 feature classes, adds some fields to one, joins, then populates those fields, removes the join, then moves on to basically what you see here, repeated a number of times based on some rules I've come up with with respect to how additional records should be populated.

 

I have done extensive testing, and everything works until I get to this CalculateField function. My calculate fields seem to do absolutely nothing. The records will select correctly based on the SelectLayerByAttribute, but then nothing calculates. Its as if the tool skips the calculate steps in the first block. However, when I get to the second block where a space exists in the text to be calculated, "Toll Road", the tool fails and I receive the following error:

 

Traceback (most recent call last):
File "C:\Users\kn815rb\Documents\ArcGIS\DataUpdates_Downloads\NavTeq_Processing_Test\NavTeq_Processing.py", line 38, in <module>
arcpy.CalculateField_management(newstreets, "TPK_SYMBL", "Toll Road", "VB", "")
File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\management.py", line 3654, in CalculateField
raise e
ExecuteError: ERROR 999999: Error executing function.
Expected end of statement
Failed to execute (CalculateField).


Failed to execute (NavTeqStreetProcessing).

 

I am guessing this means I am doing something wrong with my Calculate Fields, but I really cannot see what it is. Any ideas would be greatly appreciated!

 

Thanks!

 

import arcpy 

orgstreets = arcpy.GetParameterAsText(0)
newstreets = arcpy.GetParameterAsText(1)

arcpy.SelectLayerByAttribute_management(newstreets, "NEW_SELECTION", "\"RAMP\" = 'Y' AND \"FUNC_CLASS\" = '5'")
arcpy.CalculateField_management(newstreets, "TPK_SYMBL", "Ramp", "VB", "")
arcpy.CalculateField_management(newstreets, "GEOLAYER", "local_rds_nav", "VB", "")

arcpy.SelectLayerByAttribute_management(newstreets, "NEW_SELECTION", "\"TPK_SYMBOL\" IS NULL AND \"TOLLWAY\" = 'Y' AND \"FUNC_CLASS\" = '3'")
arcpy.CalculateField_management(newstreets, "TPK_SYMBL", "Toll Road", "VB", "")
arcpy.CalculateField_management(newstreets, "GEOLAYER", "major_hwys_nav", "VB", "")

Outcomes