1

I'm creating a table using arcpy with a list of results (stored in 2d lists) following an update to some features. This can sometimes include geometry, so I've attempted to substitute those for a basic string to avoid any conflicts - all fields are TEXT. Still, I get this error - File "I:\IPP Geomatics Standards\Toolbox\Staging\Scripts\update_attributes.py", line 93, in resultsTable cursor.insertRow([z if z is not u[index] else 'Geom' for z in u], "update") RuntimeError: table has no geometry

The 'index' variable is the known index in the list containing a geometry. This is the offending part of the function -

cursor = arcpy.da.InsertCursor(tablews + "\\results", nfields)
    for u in updatel:
        cursor.insertRow([z if z is not u[index] else 'Geom' for z in u], "update")

This should be omitting geometry altogether, but still gets flagged.

I suspect my insert statement is incorrect. As per ESRI documentation, one can insert multiple entries (i.e. one for each field) like so -

cursor.insertRow((x, y, z))

In this case, "u" is a list, and I'm trying to split it into separate entries, to the same end. The cursor must be interpreting the array as one entry, in the first field.

1

Tuple of values to cursor.InsertRow must be complete. If SHAPE@ in nfields, it has to be defined somehow. Period. You might consider creating null geometry

  • All fields are string. When I add that field in particular with the right parameters, it converts to "SHAPE_" in name and behaves like a TEXT field would, so I'm unsure where the confusion lies. I can rename the SHAPE@ field as well but I'm convinced that looping over geometry is what's causing the issue. – Sleep6 Nov 6 '14 at 17:18
  • I'm just going to scrap this and write to a csv instead, then maybe create a table from that. – Sleep6 Nov 6 '14 at 17:55
  • It's possible the issue was with the comma in the insert statement. The new line for csv is as follows - writer.writerow([z if z is not u[index] else 'Geom' for z in u] + ["update"]) – Sleep6 Nov 10 '14 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.