<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Want to add a list of domain values to a script that lists fields and field details for each feature class in a specified feature dataset in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/want-to-add-a-list-of-domain-values-to-a-script/m-p/1276046#M67363</link>
    <description>&lt;P&gt;I think this object&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/domain.htm#:~:text=The%20Domain%20object%20contains%20properties%20that%20describe%20an,properties%20can%20be%20accessed%20through%20the%20arcpy.da.ListDomains%20function." target="_blank"&gt;Domain—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;and this function&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/listdomains.htm" target="_blank"&gt;ListDomains—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;are what I would try.&amp;nbsp; The result looks like a dictionary, so should be pretty easy for format.&amp;nbsp; Hope this helps.&amp;nbsp; K&lt;/P&gt;</description>
    <pubDate>Thu, 06 Apr 2023 00:16:29 GMT</pubDate>
    <dc:creator>KimberlyGarbade</dc:creator>
    <dc:date>2023-04-06T00:16:29Z</dc:date>
    <item>
      <title>Want to add a list of domain values to a script that lists fields and field details for each feature class in a specified feature dataset</title>
      <link>https://community.esri.com/t5/python-questions/want-to-add-a-list-of-domain-values-to-a-script/m-p/1276031#M67362</link>
      <description>&lt;P&gt;Hello world!&lt;/P&gt;&lt;P&gt;I am trying to automate data dictionary creation, and am self-taught&amp;nbsp; when it comes to arcpy, so my scripting feels a bit like running blind sometimes...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Where I'm at:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My colleague and I have created a script that outputs a csv that has the layer name, field name, alias, type, length, and domain table for feature classes in specified feature datasets.&amp;nbsp; &amp;nbsp;I am running this in a notebook in ArcPro 3.0 using ArcPy 3.0.&lt;/P&gt;&lt;PRE&gt;#import modules and specify overwrite
import arcpy
import os
arcpy.env.overwriteOutput = True

arcpy.env.workspace = r"mygeodatabase.sde"

# variables:
#define csv variables and headings

headings = ["layer", "name", "alias", "type", "length", "field_domain"]
data = [headings]
outfile = r'C\\Users\myname\fileoutputlocation\outputfilename.csv'

#name csv tabs by fc and output to new tab or name stuff by FC/ds

#action stuff            
datasets = arcpy.ListDatasets(feature_type='feature')

for ds in datasets:
    if ds in ('Feature.dataset', 'other.dataset', 'other.otherdataset'):
        for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
         #List fields in feature class
            fields = arcpy.ListFields(fc)
            #Loop through fields
            for field in fields:
                #Check if field has domain
                row = [fc, field.name, field.aliasName, field.type, field.length, field.domain]
                data.append(row)

#output csv 
file = open(outfile, 'w', newline='')
with file:
  writer = csv.writer(file)
  writer.writerows(data)
print('CSV file written')&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AudreyKilloran_0-1680735807672.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67374i957AFA10295F8453/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AudreyKilloran_0-1680735807672.png" alt="AudreyKilloran_0-1680735807672.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Where I want to be:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The final step, my dear colleagues, would be to list the codes and code descriptions for the domains output by this script.&amp;nbsp; I'm not sure whether it could all be output in a specific column in the same csv, or as a separate tab on the csv for reference.&lt;/P&gt;&lt;P&gt;This is loosely what I want:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AudreyKilloran_1-1680735968073.png" style="width: 580px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67375i8A2D3D4E318B2F50/image-dimensions/580x58?v=v2" width="580" height="58" role="button" title="AudreyKilloran_1-1680735968073.png" alt="AudreyKilloran_1-1680735968073.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am stumped.&amp;nbsp; Any creative solutions?&amp;nbsp; Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 23:20:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/want-to-add-a-list-of-domain-values-to-a-script/m-p/1276031#M67362</guid>
      <dc:creator>AudreyKilloran</dc:creator>
      <dc:date>2023-04-05T23:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Want to add a list of domain values to a script that lists fields and field details for each feature class in a specified feature dataset</title>
      <link>https://community.esri.com/t5/python-questions/want-to-add-a-list-of-domain-values-to-a-script/m-p/1276046#M67363</link>
      <description>&lt;P&gt;I think this object&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/domain.htm#:~:text=The%20Domain%20object%20contains%20properties%20that%20describe%20an,properties%20can%20be%20accessed%20through%20the%20arcpy.da.ListDomains%20function." target="_blank"&gt;Domain—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;and this function&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/listdomains.htm" target="_blank"&gt;ListDomains—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;are what I would try.&amp;nbsp; The result looks like a dictionary, so should be pretty easy for format.&amp;nbsp; Hope this helps.&amp;nbsp; K&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 00:16:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/want-to-add-a-list-of-domain-values-to-a-script/m-p/1276046#M67363</guid>
      <dc:creator>KimberlyGarbade</dc:creator>
      <dc:date>2023-04-06T00:16:29Z</dc:date>
    </item>
  </channel>
</rss>

