ArcGIS – How to Extract Field Details for All Layers in a Geodatabase

arcgis-desktoparcgis-proarcpyexcelfile-geodatabase

I have inherited a file geodatabase containing a number of feature classes (points, lines and polygons), where many fields are common. For example all feature classes contain the following fields, and the fields should have the same settings:

  1. Asset_ID – should all be long numeric format with alias Asset ID
  2. GIS_ID – should all be Text with length 30 with alias GIS ID
  3. Asset_Class should be Text with length 20, alias Asset Class and Domain cvdAssetClass

I want a way to export to the field properties (Field Name, Alias, Data Type, Allow NULL, Number format, Domain, Default and Length) to a CSV or spreadsheet so I can check that all the layers are correct.

I am using ArcGIS Pro to look at the geodatabase. I have tried the "Table to Excel" command previously and combined the files and identified errors in Field Names, but I cant figure out how to confirm all the the settings are exactly the same.

Typically we export the feature classes for use in non-spatial programs, and it is important that the schemas are perfect to avoid errors when importing to the other software

Best Answer

If you are familiar with ArcPy/Python you can use ListFields. Create a list of field objects and use their properties/methods. Then create some logic to check all properties you want. Example how to access names, types, alias, etc.:

import arcpy
fc = r'C:\GIS\ArcMap_default_folder\Default.gdb\jl_sample_copy'

fields_to_check = ['KKOD','KATEGORI','Shape_Length']

fields = [f for f in arcpy.ListFields(fc)] #Create a list of field objects
#[<Field object at 0x27379ebc848[0x27303311e30]>, <Field object at 0x27379dd5f48[0x27303311d70]>, <Field object at 0x27379dd5f88[0x27303311e70]>, <Field object at 0x27379de00c8[0x273033113d0]>, <Field object at 0x27379ebe208[0x273033114b0]>, <Field object at 0x27379ebe948[0x27303311630]>]

#Filter
fields = [f for f in fields if f.name in fields_to_check]
#[<Field object at 0x273032bd9c8[0x27303311270]>, <Field object at 0x2730349ffc8[0x27303311310]>, <Field object at 0x27303841948[0x27303311cf0]>]

names = [f.name for f in fields] #They have properties, like name
#['KKOD', 'KATEGORI', 'Shape_Length']

aliases = [f.aliasName for f in fields]
#['KKOD', 'KATEGORI', 'Shape_Length']

lengths = [f.length for f in fields]
#[4, 50, 8]

types = [f.type for f in fields]
#['Integer', 'String', 'Double']

nullable = [f.isNullable for f in fields]
#[True, True, True]

domains = [f.domain for f in fields]
#['', '', ''] #No domains
Related Question