import sys, string, os, cx_Oracle, arcpy, datetime arcpy.env.workspace = "c:\\work\\scripting\\test\\testdata.gdb" arcpy.MakeFeatureLayer_management("rsids","rsid_view") rows = arcpy.SearchCursor("rsid_view","","","NUM; EXTENSION","NUM A") row = rows.next() while row: RSIDNum = str(row.getValue("NUM")) Ext = str(row.getValue("EXTENSION")) if Ext == "None": Ext = "" rsid = RSIDNum+Ext RSID = "RSID"+RSIDNum+Ext arcpy.CopyFeatures_management(RSID, "c:\\work\\scripting\\test\\testdata.gdb\\"+RSID) row - rows.next() del row del rows if arcpy.Exists("rsid_view"): arcpy.Delete_management("rsid_view") print "View deleted"
import arcpy arcpy.env.workspace = "C:\\work\\scripting\\test\\testdata.gdb" fc="rsid" outLocation="C:\\work\\scripting\\test\\output" rows = arcpy.SearchCursor(fc,"","","NUM; EXTENSION","NUM A") for row in rows: where='"FID" = '+str(row.NUM) #Note that the given field must be unique, also assumes field is a number type. We'll have to make a new where statement if NUM is a string/text arcpy.FeatureClassToFeatureClass_conversion(fc, outLocation, str(row.NUM), where) del row del rows
arcpy.FeatureClassToFeatureClass_conversion(fc, outLocation, "r"+str(row.NUM), where)
arcpy.SelectLayerByAttribute_management("rsid_view", "NEW_SELECTION", """"EXTENSION" not like 'X%' AND "EXTENSION" <> 'x'""") arcpy.SelectLayerByAttribute_management("rsid_view", "ADD_TO_SELECTION", """"NUM" = '783'""")
where='"NUM" = \''+str(row.NUM)+'\''
import arcpy arcpy.env.workspace = "C:\\work\\scripting\\test\\testdata.gdb" fc="rsid" outLocation="C:\\work\\scripting\\test\\output" rows = arcpy.SearchCursor(fc,"","","NUM; EXTENSION","NUM A") processedNUMs=[] for row in rows: num=str(row.NUM) if num in processedNUMs: continue where='"NUM" = '+num #if NUM is a number #where='"NUM" = \''+num+'\'' #if NUM is a string/text if row.EXTENSION == "None": ext="" else: ext=str(row.EXTENSION) newFCName="RSID"+num+ext arcpy.FeatureClassToFeatureClass_conversion(fc, outLocation, newFCName, where) processedNUMs.append(num) del row del rows
import arcpy arcpy.env.workspace = "C:\\work\\scripting\\test\\testdata.gdb" fc="rsids" outLocation="C:\\work\\scripting\\test\\results.gdb" rows = arcpy.SearchCursor(fc,"","","NUM; EXTENSION","NUM A") processedNUMs=[] for row in rows: num=str(row.NUM) if num in processedNUMs: continue #where='"NUM" = '+num #if NUM is a number where='"NUM" = \''+num+'\'' #if NUM is a string/text if row.EXTENSION == "None": ext="" else: ext=str(row.EXTENSION) newFCName="RSID"+num+ext arcpy.FeatureClassToFeatureClass_conversion(fc, outLocation, newFCName, where) processedNUMs.append(num) del row del rows
if ext.lower().startswith('x'): continue
if row.EXTENSION == "None" or row.EXTENSION==None:
if str(row.EXTENSION) == "None":