Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create a Data Dictionary for ArcGIS Pro Feature Classes
# generate a data dictionary from an ArcGIS feature class
# tested with ArcGIS Pro/Python3
# Run from command prompt in ArcGIS Pro environment
# Takes 2 arguments: 1) path to feature class 2) path for output CSV file
# Example: python C:\arcpy_data_dictionary.py C:\yourgeodatabase.gdb\featureclassname C:\output.csv
import arcpy
import sys
import csv
table = sys.argv[1]
outfile = sys.argv[2]
fields = arcpy.ListFields(table)
headings = ["name", "alias", "type", "length"]
data = [headings]
for field in fields:
row = [field.name, field.aliasName, field.type, field.length]
data.append(row)
file = open(outfile, 'w', newline='')
with file:
writer = csv.writer(file)
writer.writerows(data)
print('CSV file written')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment