3

this is a novice question

I have an attribute field that's missing a piece of information, i'd like to amend the attribute field like below:

This is the current attribute field:

"V:\Building & Development...."

and i'd like to add "\Engineering" to attribute field

"V:\Engineering\Building & Development...."

I have to make this change to 1441 attribute fields, not sure how to write the python script in the field calculator. I'm doing this on ArcGIS 10.2 for Desktop

3

Using the Python parser in the field calculator:

Pre-logic script code:

def convert(x):
  a = x.split(":")
  return a[0] + ":\Engineering" + a[1]

convert(!text_field!)

You can also use an UpdateCursor to do this

import arcpy

fc = r'path\to\your\fc'

with arcpy.da.UpdateCursor(fc, "your_field") as cursor:
    for row in cursor:
        if row[0] != None:
            a = row[0].split(":")
            row[0] = a[0] + ":\Engineering" + a[1]
            cursor.updateRow(row)

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.