Advertisement
Guest User

Untitled

a guest
May 5th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. import arcpy
  2.  
  3. def FindField(fc,myField):
  4. fieldList = arcpy.ListFields(fc)
  5. for field in fieldList:
  6. if str.lower(str(field.name)) == str.lower(myField):
  7. print " " + fc + " contains fieldname: " + myField
  8.  
  9. def FindField2(fc,myField2):
  10. fieldList = arcpy.ListFields(fc)
  11. for field in fieldList:
  12. if str.lower(str(field.name)) == str.lower(myField2):
  13. print " " + fc + " contains fieldname: " + myField2
  14.  
  15.  
  16. myField = "RuleID"
  17. myField2 = "Override"
  18. dir = r'D:Testgdb'
  19. arcpy.env.workspace = dir
  20.  
  21. gdbList = arcpy.ListWorkspaces('*','FileGDB')
  22.  
  23. for gdb in gdbList:
  24. arcpy.env.workspace = gdb
  25. datasetList = arcpy.ListDatasets('*','Feature')
  26. fieldList = arcpy.ListFeatureClasses()
  27. for fc in fieldList:
  28. print arcpy.env.workspace,fc
  29. print "Searching root level Featureclasses..."
  30. print " Searching " + fc
  31. FindField(fc,myField)
  32. FindField(fc,myField2)
  33.  
  34. for dataset in datasetList:
  35. arcpy.env.workspace = dataset
  36. fieldList = arcpy.ListFeatureClasses()
  37. for fc in fieldList:
  38. print arcpy.env.workspace,fc
  39. print " Searching Featureclass... " + fc
  40. FindField(fc,myField)
  41. FindField(fc,myField2)
  42.  
  43. D:TestgdbRT_FactGeology_Qld_25K.gdb Rio_FactGeology_Qld_L
  44. Searching root level Featureclasses...
  45. Searching Rio_FactGeology_Qld_L
  46. Rio_FactGeology_Qld_L contains fieldname: RuleID
  47. Rio_FactGeology_Qld_L contains fieldname: Override
  48.  
  49. D:TestgdbRT_Roads_Qld_25K.gdb Rio_Roads_Qld_L
  50. Searching root level Featureclasses...
  51. Searching Rio_FactGeology_Qld_L
  52. Rio_Roads_Qld_L contains fieldname: RuleID
  53. Rio_Roads_Qld_L contains fieldname: Override
  54.  
  55. Runtime error
  56. Traceback (most recent call last):
  57. File "<string>", line 31, in <module>
  58. File "<string>", line 6, in FindField
  59. UnicodeEncodeError: 'ascii' codec can't encode character u'xf3' in position 7: ordinal not in range(128)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement