Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> import arcpy
- ... import arcgisscripting
- ... import os
- ... import sys
- ... import types
- ... import locale
- ... #Input FC
- ... sourceFC = r"G:Backup.gdbmuni_provided_utilities_points_copy"
- ... rootdir = r"G:Orland ParkCH EAST ORLAND^WESTORLAND2"
- ... fieldsShp01 = arcpy.ListFields(sourceFC)
- ... newFields = []
- ... for file in os.listdir(rootdir):
- ... #Output shp
- ... if file.endswith(".shp"):
- ... print "The file does exist:", file
- ... fieldsShp02 = arcpy.ListFields(file)
- ... for field01 in fieldsShp01:
- ... exists = False
- ...
- ... for field02 in fieldsShp02:
- ... if (field01.name == field02.name and field01.type == field02.type and field01.length == field02.length):
- ... exists = True
- ... if (exists == False):
- ... if (field01.name != 'OBJECTID' and field01.name != 'SHAPE' and field01.name != 'CHECKED'):
- ... newFields.append([field01.name, field01.type, field01.length])
- ... exists = True
- ... for field in newFields:
- ... fieldnames = field[0]
- ... trimmed_fnames = fieldnames[0:10]
- ... arcpy.AddField_management(file, trimmed_fnames, field[1], "", "", field[2], "", "NON_NULLABLE","NON_REQUIRED","")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement