Created
December 12, 2014 16:14
-
-
Save morehavoc/3e86f535bf204b040ee2 to your computer and use it in GitHub Desktop.
Remove those pesky Shape_Length__ and Shape_Area__fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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