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)?
-
1@BERA Indeed - that will be my go-to if there isn't something quicker/easier that I've missed somehow.Midavalo– Midavalo ♦2022年02月14日 17:04:08 +00:00Commented Feb 14, 2022 at 17:04
-
1XRay 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.Son of a Beach– Son of a Beach2022年02月14日 21:13:28 +00:00Commented Feb 14, 2022 at 21:13
1 Answer 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()
Explore related questions
See similar questions with these tags.