AnsweredAssumed Answered

Remove Alph and special characters from string filed

Question asked by 2CQuiker on Aug 31, 2016
Latest reply on Sep 1, 2016 by CDow-esristaff

I have a table with a field called group_code and in this field there strings like the following.

2,10,12,15H, 26P, 35$#. As you can see some have a alph and special characters and some don't. So i don't think i can use the cursor.updateRow([row[0][1:-1]]).

 

I need to remove all the Alph and special characters at the end of each column for the group_code field.

I have tried the following but no luck. I need this to be outside the field calculator.

table = r"C:\Temp\Default.gdb\LandVal"fieldValue = "group_code"  
#Removes alpha at the end  for field in arcpy.ListFields(table, "group_code", "String"):
       exp = ''.join([i for i in fieldValue if i.isdigit()])     
arcpy.management.CalculateField(table, field, exp.format(field), "PYTHON")        
arcpy.conversion.TableToTable(table, r"C:\Temp", "LandVal_Test.dbf")

Outcomes