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 lyr.name==fc[1].split('\n')[0]: print lyr.name,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 toif lyr.name==fc[1].split('\n')[0]: print lyr.name,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\scriptutils.py", line 323, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=0) File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 655, in run exec cmd in globals, locals File "C:\Users\kyanuk\Desktop\changesearch.py", line 16, in <module> for sc in arcpy.ListFields(lyr): File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 787, in ListFields return gp.listFields(*args) File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", 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?