Select to view content in your preferred language

Simple InsertCursor crash

474
2
06-03-2011 08:52 AM
deleted-user-VeZur_n9o0OZ
Deactivated User
First time pythoner...

I'm trying to create a new empty row (from csv file) and insert in a featureclass in a file gdb.

When i do the following I crash ArcMap 10:

>>> cursor = arcpy.InsertCursor("test")
>>> row = cursor.newRow
>>> cursor.insertRow(row)


test is a point featureclass with no records.

I want to set the field values of my rows from the csv file but my 'row' object only has im_class, im_func and im_self properties. How do i set my field values and insert my row without crashing arcmap?
Tags (2)
0 Kudos
2 Replies
DarrenWiens2
MVP Alum
Your "row" objects should inherit all of the field names from the dataset that the cursor is traversing (as described here). So, you would set the values as:
cursor = arcpy.InsertCursor("test")
row = cursor.newRow()
row.fieldname1 = "value1"
row.fieldname2 = "value2"
cursor.insertRow(row)
0 Kudos
deleted-user-VeZur_n9o0OZ
Deactivated User
Thanks, I cracked it in the end. I set my feature's geometry to a point i created from coords in the csv file. I had to recreate my featureclass with upper case field aliases to stop the insert crashing arcmap.

Sorry for the duplicate thread. I can't see anywhere to mark this thread as resolved like the old style forums...
0 Kudos