arcpy.management.CalculateField(CAD_Anno, "SymbolID", "!SymbolID!.replace('0', '1')", "PYTHON3") Here is the syntax I wrote and the corresponding Error. I'm decent at python, but I am so confused about how to get this expression working. Basically, in the field of "SymbolID" I want to replace all the 0s with 1s. So the pseudocode would be "If there is a 0 in this current row of the field SymbolID, then replace it with a 1"
Traceback (most recent call last):
File "C:/Users/ggroshans/Desktop/append.py", line 14, in <module>
arcpy.management.CalculateField(CAD_Anno, "SymbolID", "!SymbolID!.replace('0', '1')", "PYTHON3")
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 5194, in CalculateField
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 5191, in CalculateField
retval = convertArcObjectToPythonObject(gp.CalculateField_management(*gp_fixargs((in_table, field, expression, expression_type, code_block, field_type, enforce_domains), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 000539: File "<expression>", line 1
0.replace('0', '1')
^
SyntaxError: invalid syntax
Failed to execute (CalculateField).