select by attribute with a loop

Discussion created by smilmaster on Feb 23, 2012
Latest reply on Feb 23, 2012 by smilmaster
Hi everybody,

I have a polygon shipfile with thousand objects and each has a sole value stored in a field. The values are stored in

order, for example, 1, 2,3,4, ...... I want to generate new shipfiles each with only one object. This can be done by

select tool under the Extract toolbox. As i have thousands objects, using the toolbos is time consuming. I believe

python can do this work well with a loop. however, i am a beginner, and not familar with it. I spent a whole day to try

fullfilling this work but failed. Can anybody help me write the code? Or give me some tips. Thank you very much in


the code for the select is like:

arcpy.Select_analysis("C:/majorrds.shp", "C:/output/majorrdsClass4.shp", '"CLASS" = '4'')  Can we change the

number "4" automatically with a loop? and how? Thank you!

Sincerely Xiaoma Li