I am trying to remove specific characters from a field called CCTV_SLID. The field I am working with looks like this CLMH123W456MH123W455, STMH123W457, SIMH123W458, SYMH123W459. I am trying to remove the prefixes which are CL, ST, SI, and SY. I have the following script and get a IOError: "C" does not exist error. Any help would be appreciated. Thanks.
# Remove prefix from CCTV_SLID
fcLst = "C:/Desktop/CCTV.gdb/GravityMain"
for fc in fcLst:
fieldList = [f.name for f in arcpy.ListFields(fc) if f.type == "String"]
if fieldList:
with arcpy.da.UpdateCurson(fc, fieldList) as cursor:
for row in cursor:
for i in range(len(fieldList)):
row = row.replace("CL"," ")
cursor.updateRow(row)
Solved! Go to Solution.
Thank you all for your help. I really appreciate it.