Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Remove those pesky Shape_Length__ and Shape_Area__fields
print "Importing arcpy"
import arcpy
from os.path import join
workspace = r"path to .sde connection here"
fields_to_remove = ["Shape_STLength__", "Shape_STArea__"]
arcpy.env.workspace = workspace
print "Listing Feature Classes"
layers= arcpy.ListFeatureClasses()
for layer in layers:
print "Processing {}".format(layer)
layer_path = join(workspace, layer)
fields = [f.name for f in arcpy.ListFields(layer_path)]
for field in fields_to_remove:
if field in fields:
print " Removing {}".format(field)
try:
arcpy.DeleteField_management(layer_path, field)
except Exception as e:
print e
pass
print "Complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment