First time poster so I hope I did this right. I'm relatively new to Python scripting and am trying to understand the error I'm getting.
I have the following simple code and what I don't understand is why PAD_HI_250extent generates the Method fields does not exist error? They are both polygon feature classes stored in the same file gdb. Is there a difference in the two feature classes that I'm not aware of? Can the content of the fields, as opposed to the field name themselves, affect this (I do know that there are special characters, e.g., K'au Forest Reserve)
Running ArcMap 10.1 on Win7, Python 2.7.2
================================================================================= SCRIPT ====== import arcpy, time ## set environment settings arcpy.env.overwriteOutput=True arcpy.env.workspace = r"F:USERFLATHERTE_AtRisk_grid_modelFeatureClasses.gdb" files = ["BOC_HI_BG_250extent", "PAD_HI_250extent"] for file in files: print 'File:', file desc = arcpy.Describe(file) fieldnames = [f.name for f in desc.fields if f.type not in ["Geometry", "Raster", "Blob"]] print fieldnames print"================================================================================== OUTPUT ====== File: BOC_HI_BG_250extent [u'OBJECTID', u'FID_HI_fishnet_250sqmi', u'FID_BOC_HI_BlockGroups', u'STATEFP', u'COUNTYFP', u'TRACTCE', u'BLKGRPCE', u'GEOID', u'NAMELSAD', u'MTFCC', u'FUNCSTAT', u'ALAND', u'AWATER', u'INTPTLAT', u'INTPTLON', u'Shape_Length', u'Shape_Area', u'tot_area', u'fishnetID'] File: PAD_HI_250extent Traceback (most recent call last): File "F:/USER/FLATHER/TE_AtRisk_grid_model/scripts/DDD_descfields.py", line 15, in
fieldnames = [f.name for f in desc.fields if f.type not in ["Geometry", "Raster", "Blob"]] AttributeError: DescribeData: Method fields does not exist >>>
Describefunction is well documented at ArcGIS Resource Center. It is a quit big topic to define in here. So, have a look at the given link.
In your case, the item
fields. As pointed by MWrenn above. It is wise to check the
desctype first before calling its properties.