<SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> master_dict </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">{</SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">'Alabama'</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">:</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">[</SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">'01009'</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">,</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">'01013'</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">],</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">...}</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> statePath </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">"<...>/gdb/master_merge_footprints.gdb"</SPAN>I want to iterate through the gdb and find specific features based on state names. This part works. I can even print the fields just to test that the feature class exists:
<SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> stateNames </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">[</SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">'Alabama'</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">,</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">'Alaska'</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">...]</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">for</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> name </SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">in</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> stateNames</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">:</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> arcpy</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">env</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">workspace </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> statePath featureclasses </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> arcpy</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">.</SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">ListFeatureClasses</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">()</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> fip_merge_list </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">[]</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">for</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> fc </SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">in</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> featureclasses</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">:</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">if</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> name </SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">in</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> fc</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">:</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">print</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> fc fipslist </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">(</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">master_dict</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">[</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">name</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">]):</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">for</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> fip </SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">in</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> fipslist</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">:</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #858c93; border: 0px; font-weight: inherit; font-size: 13px;">### Here's where the problem occurs</SPAN>
Here is where the problem occurs. As I mentioned if I've tried several things to make sure that fcexists, including fieldnames = [field.name for field in arcpy.ListFields(fc)]. I am able to print the field names and verify that the field for the where clause also exists. I create a hard output path to an existing gdb just to make sure the process will work. When I run this however, nothing shows up in my gdb when I check in ArcMap. I can manually run a selectByAttributes function in ArcMap directly on this fc as well.
<SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">select </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> arcpy</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">.</SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">MakeFeatureLayer_management</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">(</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">fc</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">,</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> statePath </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">+</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">"/%s_temp_lyr_%s"</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">%(</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">name</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">,</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> fip</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">),</SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">"FIPS_CODE = '%s'"</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">%(</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">fip</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">))</SPAN>
The process runs and doesn't throw an error, but nothing is showing in my gdb. So I tried just using the SelectLayerByAttributes_management with fc and it throws an error:
<SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">select_1 </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> arcpy</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">.</SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">SelectLayerByAttribute_management</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">(</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">fc</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">,</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">"NEW_SELECTION"</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">,</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> </SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">"FIPS_CODE = '%s'"</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">%(</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">fip</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">))</SPAN>
Traceback (most recent call last): File "", line 1, in select_1 = arcpy.SelectLayerByAttribute_management (fc, "NEW_SELECTION", "FIPS_CODE = '%s'"%(fip)) File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 4259, in SelectLayerByAttribute raise e ExecuteError: Failed to execute. Parameters are not valid. The value cannot be a feature class ERROR 000840: The value is not a Raster Layer. ERROR 000840: The value is not a Mosaic Layer. Failed to execute (SelectLayerByAttribute).
So, I can't make a layer from my feature class, I can't select by attributes, and I am stuck. I have manually verified that the feature class exists (both in Python and ArcMap), I have verified that the field exists, and I have verified that the fip exists. Any advice on what I am doing incorrectly here?