How do you get a summary of a feature class schema?

1840
4
Jump to solution
12-10-2012 02:18 PM
PaulHuffman
Occasional Contributor III
Maybe I'm over thinking this, but I'm trying to MERGE or APPEND some old shapefiles into an existing geodatabase feature class.  I know I'm going to be dropping many of the GPS generated fields and adding new ones, typing the fields to so input will match with the existing schema.  But I'm disappointed that I can't find a way to list and print out the existing feature class schema so all the types and widths are displayed.  ArcCatalog seems to only be able to show with feature class properties only the first 13 items, then I have to page down to see the rest.  Then I have to look at the properties of each field to find out the field length.  Isn't there a way to list out a summary of the whole schema?

Are there any other tools to help get matching schemas before a MERGE?
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Hi Paul,

You could use python to list the field name, type, and length:

import arcpy from arcpy import env env.workspace = r"C:\temp\python\test.gdb"  fc = "Airports"  for field in arcpy.ListFields(fc):     print field.name, field.type, field.length

View solution in original post

0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor
Hi Paul,

You could use python to list the field name, type, and length:

import arcpy from arcpy import env env.workspace = r"C:\temp\python\test.gdb"  fc = "Airports"  for field in arcpy.ListFields(fc):     print field.name, field.type, field.length
0 Kudos
RichardFairhurst
MVP Honored Contributor
If your features are in a geodatabase you can use the Export option that outputs to an XML Workspace Document.  The output file can be opened in Excel, manipulated and printed out.  The output lists everything in the schema, including field types, aliases, domain information, default values, etc.  Shapefiles do not have this option, but you could import them raw into a geodatabase and output it fairly easily.
markdenil
Regular Contributor II
You can also export the table to a text file.
You can throw the actual text file away,
but the export also produces a schema.ini file.

It is a text file with (you guessed it) the table schema.

example:
[Arctic.txt]
Format=CSVDelimited
ColNameHeader=True
Col1=OBJECTID Long
Col2=NAME Text Width 50
Col3=ABBR Text Width 10
Col4=ICECODE Text Width 45
Col5=CT Text Width 2
Col6=CA Text Width 2
... and so on ...
Col19=COLOR Text Width 2
Col20=LABEL Text Width 6
Col21=POLY_TYPE Text Width 2
Col22=Shape_area Double
Col23=Shape_len Double

If you have exported more than one table to text in that directory,
each exported schema is appended to the schema.ini

For a long table, you can export a selection to save time and disc space.
0 Kudos
PaulHuffman
Occasional Contributor III
I liked Jake's suggestion since I usually have a python window open. I just added a few changes to make it list to a file by creating a writable object:
#Open output text file
log = open('listfields.txt', 'w')

for field in arcpy.ListFields(fc):
    print >> log, field.name, field.type, field.length

log.close() 


I tried Richard's suggestion to export to XML.  I got so much information out that I thought it didn't work for the field types and widths at first, but after scrolling around in Excel I eventually found it.

mdenil's suggestion to export the table to text worked pretty well too. I just had to figure out that to find this option, I had to go to ArcCatalog, preview the table, then at the bottom left is a icon with a pulldown arrow that gives me Export as one of the choices. 

Thanks, all.
0 Kudos