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 <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\Temp\Default.gdb\LandVal"</SPAN>fieldValue <SPAN class="operator token">=</SPAN> <SPAN class="string token">"group_code"</SPAN>
<SPAN class="comment token">#Removes alpha at the end for field in arcpy.ListFields(table, "group_code", "String"):</SPAN>
exp <SPAN class="operator token">=</SPAN> <SPAN class="string token">''</SPAN><SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> fieldValue <SPAN class="keyword token">if</SPAN> i<SPAN class="punctuation token">.</SPAN>isdigit<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>management<SPAN class="punctuation token">.</SPAN>CalculateField<SPAN class="punctuation token">(</SPAN>table<SPAN class="punctuation token">,</SPAN> field<SPAN class="punctuation token">,</SPAN> exp<SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>field<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"PYTHON"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>conversion<SPAN class="punctuation token">.</SPAN>TableToTable<SPAN class="punctuation token">(</SPAN>table<SPAN class="punctuation token">,</SPAN> r<SPAN class="string token">"C:\Temp"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"LandVal_Test.dbf"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>