Guest User

Untitled

a guest
Jul 18th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. ## Specify the File Geodatabase workspace
  2. gdb = "C:\\Users\\XXXXXXXX\\Documents\\ArcGIS\\Projects\\XXXX.gdb"
  3.  
  4. ## Get a list of domains
  5. desc = arcpy.Describe(gdb)
  6. domains = desc.domains
  7.  
  8. ## Loop over the list of domains
  9. for domain in domains:
  10. ## Create an object that represents the name of the Excel file to be created
  11. table_name = domain + '.xlsx'
  12. ## Let the user know what is happening
  13. print('Exporting {0} domain to table {1}'.format(domain, table_name))
  14. ## Create an object that represents the full path of the Excel file to be created
  15. table_full_path = os.path.join(os.path.dirname(gdb), table_name)
  16. ## Create an in memory object for the DBF to temporarily store the domains (since this is the default file type)
  17. in_memory_dbf = "in_memory" + "\\" + domain + ".dbf"
  18. ## Export the domain to the temporary in memory table
  19. ## NOTE: Cannot use "description," that is longer than 10 characters
  20. arcpy.DomainToTable_management(gdb, domain, in_memory_dbf, 'field', 'desc', '#')
  21. ## Convert the in memory table to an Excel stored on disc
  22. arcpy.TableToExcel_conversion(in_memory_dbf, table_full_path)
  23. ## Clear the memory so ArcGIS doesn't pitch a fit
  24. arcpy.Delete_management("in_memory")
Add Comment
Please, Sign In to add comment