AnsweredAssumed Answered

arcpy.ListFields() returning "does not exist"

Question asked by kyanuk1 on Sep 7, 2012
Latest reply on Sep 7, 2012 by kyanuk1
I'm looking to compare a text file of features classes and their fields to those in a map doc.

I'm using:

for de in searchfile.readlines():     if '--' in de:         fc=de.split('--')         for lyr in arcpy.mapping.ListLayers(mxd):             if[1].split('\n')[0]:                 print,type(lyr)                 for sc in arcpy.ListFields(lyr):                     if not sc in searchfile.readlines():                         print sc

where the first few lines are just string parsing the text file to locate the featureclass names.  I can get to

if[1].split('\n')[0]:     print,type(lyr)

which prints the names of the layers fine, along with the type "<class 'arcpy._mapping.Layer'>"

edit: However, it returns the following when I try to ListFields:

Traceback (most recent call last):   File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\framework\", line 323, in RunScript, __main__.__dict__, start_stepping=0)   File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\debugger\", line 60, in run     _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)   File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\debugger\", line 655, in run     exec cmd in globals, locals   File "C:\Users\kyanuk\Desktop\", line 16, in <module>     for sc in arcpy.ListFields(lyr):   File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\", line 787, in ListFields     return gp.listFields(*args)   File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\", line 342, in listFields     self._gp.ListFields(*gp_fixargs(args))) IOError: "SIDEWALK" does not exist

Can ListFields() be used this way for these featureclasses in my map doc?