import sys, string, os, arcgisscripting
gp = arcgisscripting.create(9.3)
gp.AddToolbox("C:/Program Files (x86)/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
# Variables in local
lines_shp = "d:\\Travaux\\NantesMetropole\\lines.shp"
test = ["blines"]
while 1:
for i in test:
try:
gp.Select_analysis(lines_shp, i_shp, i)
print "Query successful"
except:
print "Error"
break
import arcpy
arcpy.env.overwriteOutput = True
fc = "H:/GIS_Data/TEMP.gdb/points" # path to input feature class
field = "mapnumber" # field name to get unique values
arcpy.MakeFeatureLayer_management(fc, "lyr") # make feature layer
rows = arcpy.SearchCursor(fc, "", "", "", field) # make cursor, sort by field
firsttime = 1
prev = -1
for row in rows: # loop through each feature
current = row.getValue(field) # get current field value
if firsttime == 1 or prev != current:
prev = row.getValue(field) # set prev to current value
arcpy.SelectLayerByAttribute_management("lyr", "NEW_SELECTION", field + " = " + str(current))
arcpy.CopyFeatures_management("lyr", "H:/GIS_Data/TEMP.gdb/pt_" + str(current))
arcpy.Delete_management("lyr")
del row
del rows
#DISCLAIMER: Untested code - just typed it on the fly - may not work "out of the box" import arcpy myFC = r"C:\temp\my_fc.shp" oidFieldName = arcpy.Describe(myFC).OIDFieldName searchRows = arcpy.SearchCursor(myFC) for searchRow in searchRows: oidFieldValue = searchRow.getValue(oidFieldName) outFC = r"C:\temp\output_" + str(oidFieldValue) + ".shp" arcpy.Select_analysis(myFC, outFC, oidFieldName + " = " + str(oidFielValue)) del searchRow, searchRows
If you want every feature exported as a seperate feature class, you would probably want to use the OBJECTID field (or some other unique ID field).