AnsweredAssumed Answered

Removing/Replacing specific characters from a field

Question asked by hnavarro23 on Oct 31, 2018
Latest reply on Nov 14, 2018 by curtvprice

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 = [ 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[i] = row[i].replace("CL"," ")