mdly68

Adding same field to X different feature classes

Discussion created by mdly68 on Apr 18, 2014
Latest reply on Apr 18, 2014 by mdly68
Hello! One of my goals this year is to start getting familiar with python. I'm still very new though I've taken programming courses in other languages. Let's say I have 10 different fields to be added to 100 different feature classes. I located a script on another forum where someone needed to add fields to thousands of shapefiles in a single directory. I'm trying to modify it to work with my personal geodatabase and this is likely a simple syntax issue.

Here is my script, I'm getting an error saying "NoneType object has no attribute 'Next'". I THINK this means I'm not getting a list of feature classes to work through?

Edit: I've moved the features outside the dataset so they are stand-alone, but the same error occurs.

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

gp.Workspace = "C:\Coops\07015 Morgan County\MapEdit\GISBlank93.mdb"

shpList = gp.ListFeatureClasses("*")
shp = shpList.Next()
print "shp = " + shp
while shp:
  if not gp.ListFields(shp, "FIELD1").Next():
    print "Adding FIELD1 to " + shp + "..."
    gp.AddField_management(shp, "FIELD1", "TEXT", "", "", "15", "", "NULLABLE", "NON_REQUIRED", "")
  shp = shpList.Next()

Outcomes