Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. >>> import arcpy
  2. ... import arcgisscripting
  3. ... import os
  4. ... import sys
  5. ... import types
  6. ... import locale
  7. ... #Input FC
  8. ... sourceFC = r"G:Backup.gdbmuni_provided_utilities_points_copy"
  9. ... rootdir = r"G:Orland ParkCH EAST ORLAND^WESTORLAND2"
  10. ... fieldsShp01 = arcpy.ListFields(sourceFC)
  11. ... newFields = []
  12.  
  13. ... for file in os.listdir(rootdir):
  14. ... #Output shp
  15. ... if file.endswith(".shp"):
  16. ... print "The file does exist:", file
  17. ... fieldsShp02 = arcpy.ListFields(file)
  18. ... for field01 in fieldsShp01:
  19. ... exists = False
  20. ...
  21. ... for field02 in fieldsShp02:
  22. ... if (field01.name == field02.name and field01.type == field02.type and field01.length == field02.length):
  23. ... exists = True
  24. ... if (exists == False):
  25. ... if (field01.name != 'OBJECTID' and field01.name != 'SHAPE' and field01.name != 'CHECKED'):
  26. ... newFields.append([field01.name, field01.type, field01.length])
  27. ... exists = True
  28. ... for field in newFields:
  29. ... fieldnames = field[0]
  30. ... trimmed_fnames = fieldnames[0:10]
  31. ... arcpy.AddField_management(file, trimmed_fnames, field[1], "", "", field[2], "", "NON_NULLABLE","NON_REQUIRED","")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement