import arcpy
code = ["007","013","014","015","017","019","021","023","027","029","031","033","035","037","039","041","043","045","047","049","051","055","059","063","065",
"067","069","075","077","081","083","085","091","097","099","101","103","105","107","109","113","117","119","123","125"]
cnty = ["Archuleta","Boulder","Broomfield","Chaffee","Cheyenne","Clear_Creek","Conejos","Costilla","Custer","Delta","Denver","Dolores","Douglas","Eagle","Elbert","El_Paso","Fremont","Garfield",
"Gilpin","Grand","Gunnison","Huerfano","Jefferson","Kit_Carson","Lake","La_Plata","Larimer","Logan","Mesa","Moffat","Montezuma","Montrose","Ouray","Pitkin","Prowers","Pueblo","Rio_Blanco",
"Rio_Grande","Routt","Saguache","San_Miguel","Summit","Teller","Weld","Yuma"]
try:
arcpy.SelectLayerByAttribute_management("Colorado_Clip","NEW_SELECTION",""""COUNTY_CODE" = code[0]""")
arcpy.CopyFeatures_management("Colorado_Clip","H:/GIS DATA/Data/Conflation/RPAM Data NAD83.gdb/Colorado/" + cnty[0],"#","0","0","0")
arcpy.SelectLayerByAttribute_management('Colorado_Clip', "CLEAR_SELECTION")
del cnty[0]
del code[0]
print cnty
print code
except:
print code[0] + " Failed"Above is my simple script.
The goal is to loop through the items on the list, select attributees and create a new shapefile based on the name in the list, clear my selection, del that item from the list and move on to the next one.
Problem I am running into is in line 10 where the {where_clause} is. The tool does not want to take a list item for the value (code[0]) is not acceptable. Is there a way around this so i can use my list I don't want to have to type all of these out manually.
Orginially i wanted to split this file, but the size of the file prevents me from doing this. I also have to do this for 8 more states.
Anyone have any ideas?