ahigh2

InsertCursor Row Name Variable Issue

Discussion created by ahigh2 on Sep 8, 2011
Latest reply on Sep 8, 2011 by ahigh2
Hi,

I'm working on a script that will take a python list of field names and then iterate through them in an InsertCursor to use them as the names of fields to update. The problem here is that the insert cursor seems to take the field name literally (e.g. row.<something>), where the <something> is taken literally as the name of the field, making it impossible to pass a variable in. If anyone has a workaround for this, I would certainly appreciate it. Below I've provided a short snippet of the loops I've put together to accomplish what I want to do:
Note: The list of updated features is parsed from a JSON URL.
for items in updateFeatures["features"]:
  row=cursor.newRow()
  for i in range(0,len(fieldList))):
    row.fieldListing[i]=items["attributes"][fieldListing[i]] #The problem is here with the left fieldListing[i]
  cursor.insertRow(row)


Thanks,

Aaron H.

Outcomes