How to store the arcpy.da.ListDomains(gdb) domaincoded values inside a dictionary using python/arcpy
Solved! Go to Solution.
Can you be more specific? What are you trying to do with the "stored" domain? Does it need to be in any particular format?
Once you get the list of domains from arcpy.da.ListDomains, you should just be able to iterate through the response and do whatever you need it to.
doms = arcpy.da.ListDomains('some gdb')
dom_dict = {}
for d in doms:
dom_dict[d.name] = {
'type': d.domainType,
'codedValues': d.codedValues,
'range': d.range
}
Can you be more specific? What are you trying to do with the "stored" domain? Does it need to be in any particular format?
Once you get the list of domains from arcpy.da.ListDomains, you should just be able to iterate through the response and do whatever you need it to.
doms = arcpy.da.ListDomains('some gdb')
dom_dict = {}
for d in doms:
dom_dict[d.name] = {
'type': d.domainType,
'codedValues': d.codedValues,
'range': d.range
}
Suppose i get the codedValues from arcpy.da.ListDomains(gdb) by iterating over it then in codedValues we get code and value like a dictionary of values {0:'value1',1:'value2'} so i want to store this dictionary value into another dictionary from i can access these values as key,value .
You could do that. You'd have to be careful, in case there were duplicate codes in your database.
values_dict = {}
for d in doms:
for c in d.codedValues:
values_dict[c] = d.codedValues[c]