sehre

Using CopyFeatures for python script

Discussion created by sehre on Mar 22, 2011
Latest reply on Mar 23, 2011 by sehre
Hi, I tried to write a small scritp which copies each row of a feature class to a new file. I wanted to use the CopyFeatures function to create the new files, but when I run the modul I get this error message back:

AttributeError: 'NoneType' object has no attribute 'CopyFeatures_management'

I am not sure what the problem exactly is and how to solve it. Any suggestions?

This is the code I wrote:
# Import arcpy module
import arcpy
from arcpy import env
import os

env.workspace = r"C:\ArcGIS\Mexico.gdb"

# Load required toolboxes
arcpy.ImportToolbox("C:\Programme\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes\Data Management Tools.tbx")

# Local variables:
cities_mexico = "cities_mexico"

searchCursor = arcpy.SearchCursor(cities_mexico)
row = searchCursor.next()

while row <> None:
    # Process: Copy Features        
    outFeature = os.path.join(env.workspace, row.CITY_NAME)
    print outFeature
    arcpy.CopyFeatures_management(row, outFeature)

Outcomes