On the ESRI-L mailing list this morning there was a question about how to see or export all the coded value domains for a geodatabase. The goal is to present the content of the domains in a tabular form, so they're easy to read.

The DomainToTable tool does this easily for a single domain, but when there are many domains it quickly grows tiresome. The best advice I could give was to the batch processing feature, but even that requires knowing or looking up the names of domains individually.

Surely there's a better way?

  • 1
    Can probably adapt this code (see Chris Snyder's post) to get at what you want: forums.arcgis.com/threads/…
    – blah238
    May 25, 2012 at 17:59
  • All of the domains are listed in the "DomainName" field of the GDB_Domains table. You could easily loop over the names and feed them into the DomainToTable geoprocessing tool through simple code. You also need to be careful with SubTypes as each SubType can potentially have it's own domain. May 25, 2012 at 18:09
  • @BrentEdwards, where do you see a GDB_Domains table? I opened up a personal-gdb with domains in Access and it isn't there. I did find GDB_Items with a Definition field which appears to contain the domains, but they're buried in XML. May 25, 2012 at 18:24
  • Are you using ArcGIS 10? GDB_Domains existed only in 9.3 and earlier. See: blogs.esri.com/esri/arcgis/2010/03/15/…
    – blah238
    May 25, 2012 at 18:37
  • thanks for that page @blah238. I didn't know about that (and yes I'm using v10) May 25, 2012 at 18:43

2 Answers 2


Here is something I put together that works on the simple gdb's I have on hand. I don't know how it might or might not handle sub-types with multiple domains (see Brent's comment).


python export_gdb_domains.py [input geodatabase]

It exports the tables to the same gdb it's getting the domains from. It will fail if the table(s) exist already.

''' Export all coded value domains in a geodatabase to tables in that gdb '''
import os, sys
import arcpy

gdb = sys.argv[0]

desc = arcpy.Describe(gdb)
domains = desc.domains

for domain in domains:
    print 'Exporting %s CV to table in %s' % (domain, gdb)
    table = os.path.join(gdb, domain)
    arcpy.DomainToTable_management(gdb, domain, table,
        'field','descript', '#')

Updated version on github at https://github.com/envygeo/arcplus/blob/master/ArcToolbox/Scripts/export_gdb_domains.py. Optionally writes to XLS and overwrites existing tables.



I initially tried to use an output directory and .csv files for the results instead, but kept getting "ERROR 000142: Field name in dBASE table cannot be longer than 10 characters". It seems to always interpret the path as part of the table name (c.f. table = line) {shrug}.

[Later]: @dgj32784 found the cause, 'description' at 11 characters is too long.

  • I have found that CSV export in geoprocessing is essentially nonexistent, although you can do it interactively through the Export Data dialog in ArcMap. I usually just use the Python csv module.
    – blah238
    May 25, 2012 at 19:07
  • 1
    On CSV export, see related question: gis.stackexchange.com/questions/26227/…
    – blah238
    May 25, 2012 at 19:27

Here's some code that exports all the domains to Excel files. Also, you are getting the error when trying to export to DBF because the word "description" is 11 characters long.

''' Export all coded value domains in a geodatabase to Excel files in the same directory '''
import os, sys
import arcpy

## Ideal when testing so you don't keep getting errors
arcpy.env.overwriteOutput = True

## Specify the File Geodatabase workspace
gdb = sys.argv[0]

## Get a list of domains
desc = arcpy.Describe(gdb)
domains = desc.domains

## Loop over the list of domains
for domain in domains:
    ## Create an object that represents the name of the Excel file to be created
    table_name = domain + '.xls'
    ## Let the user know what is happening
    print('Exporting {0} domain to table {1}'.format(domain, table_name))
    ## Create an object that represents the full path of the Excel file to be created
    table_full_path = os.path.join(os.path.dirname(gdb), table_name)
    ## Create an in memory object for the DBF to temporarily store the domains (since this is the default file type)
    in_memory_dbf = "in_memory" + "\\" + domain + ".dbf"
    ## Export the domain to the temporary in memory table
    ## NOTE: Cannot use "description," that is longer than 10 characters
    arcpy.DomainToTable_management(gdb, domain, in_memory_dbf, 'field', 'desc', '#')
    ## Convert the in memory table to an Excel stored on disc
    arcpy.TableToExcel_conversion(in_memory_dbf, table_full_path)
    ## Clear the memory so ArcGIS doesn't pitch a fit

EDIT: fixed print format (line 20)

  • thanks for the 'description' bug fix! I've added it to my script Jun 6, 2019 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.