This is the attribute table values of two fields but the values inside the fields are domain coded description values by using search cursor i am getting only the code not the values need help or suggestions for that.
Use the list domains and find it for your featurclass:
domains = arcpy.da.ListDomains("C:/Boston/Boston.gdb") for domain in domains: print(f"Domain name: {domain.name}") if domain.domainType == "CodedValue": coded_values = domain.codedValues for val, desc in coded_values.items(): print(f"{val} : {desc}")
I have tried this way but i am getting all the domain coded values for that but i need only the field values like shown in the image. Kindly give me some suggestions on that please.
Filter on the field?
fc = r'path to your fc' field = 'Field you want' target_field = [f for f in arcpy.ListFields(fc) if field == f.name] if target_field[0].domain: field_domain = [d for d in arcpy.da.ListDomains(arcpy.Describe(fc).path) if d.name == target_field[0].domain][0] for k,v in field_domain.codedValues.items(): print(f'domain key: {k} domain value: {v}')
Traceback (most recent call last):File "D:\ARCPY\ArcPy_New\feature_exists.py", line 182, in <module>if target_field[0].domain:IndexError: list index out of range
Getting this error
Attaching the code also
Here one more information is that ASSETGROUP field is a subtype field.
Instead of sending a list of fields, send a single field.
Yes, i tried it also but i'm not getting any result also not getting any error.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.