with arcpy.da.UpdateCursor(inFeatures, "[TDS_Name]") as change_cursor:
for x in change_cursor:
if x[0] == None:
x[0] = x[0]
else:
x[0] = x[0].translate("-F", " ")
change_cursor.updateRow(x)
del change_cursor
RuntimeError: An invalid SQL statement was used. [SELECT [TDS_Name], OBJECTID FROM Test_Pit_2]
My purpose: Replace "-" with a " ", but only the first "-" in the ["TDS_Name"] field.
examples in TDS_Name: 1000-XX5, 4000-XX3, 3000-XX35-1
What they should be in the end: 1000 XX5, 4000 XX3, 3000 XX35-1
I used this line here which worked, but if I ran the script again would, unfortunately, remove the second "-":
arcpy.CalculateField_management(inFeatures, "TDS_Name", "!TDS_Name!.replace('-',' ', 1)", "PYTHON3", '', "TEXT")
I have imported ArcPy, and my workspace was set and the features showed up with the Exists function.
I tried using .replace in the UpdateCursor, but it didn't work and there is obviously an issue with my setup of the cursor in the first place.
["TDS_Name"]
not"[TDS_Name]"
.