Skip to content

Instantly share code, notes, and snippets.

@steveoh steveoh/

Last active Jul 11, 2020
What would you like to do?
list usused domains and fields with domain
from pprint import pprint
import arcpy
arcpy.env.workspace = r'stage.sde'
output = {}
tables = []
for dirpath, dirnames, walked_tables in arcpy.da.Walk(datatype=['FeatureClass', 'Table']):
#: filter for tables owned by the user
tables += walked_tables
domain_names = set([ for x in arcpy.da.ListDomains()])
used_domains = set([])
for table in tables:
print('inspecting ' + table)
domains = {}
for field in arcpy.ListFields(table):
print(' inspecting ' +
if field.domain:
print(' field has domain ' + field.domain)
domains[] = field.domain
if len(domains.keys()) > 0:
output[table] = domains
print('unused domains')
pprint(domain_names - used_domains)
print('fields with domains')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.