Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Remove first 2 characters using if statement

$
0
0
Hi, I would like to have this code remove and XY or RR (if they are the first 2 characters) in a field with values

XY2365541
RR1247884
8965445

would be:

2365541
1247884
8965445

Writing a query is giving me trouble. I was trying this code with a search cursor, getvalue and if elif statement...but no luck

Code:

import arcpy
Feature_Class_Name = arcpy.GetParameterAsText(0)
Output_Features = arcpy.GetParameterAsText(1)
arcpy.env.workspace = r"H:/TestMDB.gdb/XY_1"
cursor = arcpy.da.UpdateCursor(Feature_Class_Name, ["NM"])
for row in cursor:
    cursor.updateRow([row[0][2:]])
del fc


Viewing all articles
Browse latest Browse all 2485

Trending Articles