2

I am wanting to do a visual table-structure comparison of feature classes in an enterprise GDB to feature classes in a File GDB. Just want to compare things like field names and types.

Is there a way to quickly export the table structure from GDB to Excel?

I don't need the actual data, just the field names and types, and maybe alias. Export table structure information to Excel QGIS or MapInfo is a similar question (but for different GIS software).

I know I can get this information by using ArcPy Describe, but I really don't want to spend much time on it, and am thinking there's possibly a right-click type function in ArcCatalog, or maybe something in Toolbox, I just can't find anything right now. The closest I've found is exporting the workspace XML, but this is a bit messier than I'd like.

Is there a tool or function in ArcGIS Desktop to output the table structure to Excel (XLS, XLSX, CSV, etc)?

2
  • 1
    @BERA Indeed - that will be my go-to if there isn't something quicker/easier that I've missed somehow.
    – Midavalo
    Feb 14, 2022 at 17:04
  • 1
    XRay for ArcCatalog is the way to go for documenting your GDB schema. See: arcgis.com/home/item.html?id=35e14ba8a03d49188ee8ead2e79f24d3 . It's not for Excel particularly (although I did once write a script to parse the HTML into CSV for import to Excel). The HTML output that it can produce is the best way to document and review GDB schema. Feb 14, 2022 at 21:13

1 Answer 1

1

This code will output the field info for all the tables to a spreadsheet.

import pandas as pd
import openpyxl

# define workspace and output
arcpy.env.workspace = r"path\to\gdb.gdb"
excel_file = r"spreadsheet.xlsx"

writer = pd.ExcelWriter(excel_file, engine='openpyxl')

#for each table
for tbl in arcpy.ListTables():
    #create empty pandas dataframe
    df = pd.DataFrame(columns = ['Name', 'Alias','Type','Length','Domain'])
    #loop through fields and add rows to df
    for field in arcpy.ListFields(tbl):
        df.loc[len(df.index)] = [field.name, field.aliasName, field.type, field.length,field.domain]
    #then save to Excel
    df.to_excel(writer, sheet_name=tbl,index=False)
writer.save()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.