I am trying to split a feature layer by rows. I've previously some time ago been able to use the below script, however now when I use it, it returns:
Python ERROR 000840: The value is not a Feature Layer
import arcpy
outputNum = 5000000
outputFCName = "Flows"
def listSplit(myList, n):
for i in xrange(0, len(myList), n):
yield myList[i:i + n]
arcpy.env.workspace = r"C:\...\Database.gdb" #The dots are replaced with a proper path
lyr = arcpy.mapping.Layer("Layername")
arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")
fList = list()
with arcpy.da.SearchCursor(lyr, "OID@") as cursor:
for row in cursor:
fList.append(row[0])
listGroup = listSplit(fList, outputNum)
for x in listGroup:
lyr.setSelectionSet("NEW", x)
arcpy.CopyFeatures_management(lyr, arcpy.CreateUniqueName(outputFCName))
The reason for splitting is that I have a dataset with 24.000.000 rows, which I would prefer in smaller parts.
print type(lyr), what output? Try using MakeFeatureLayer