tony.farndon

Dynamically set an InsertCursor row.<object>

Discussion created by tony.farndon on May 24, 2011
Latest reply on May 24, 2011 by dkwiens
Hi

I am trying to create a table from a python dictionary, the keys,values of which are not typed via code but read in from elsewhere.

I have got as far as reading the column key,value to create the table field

for columnName, columnValue in columnDict.iteritems():
        arcpy.AddField_management(inFeatures, columnName, "TEXT", "", "", 50)
        ...


However, when I then come to use the insert cursor to add values to the fields a little later on in the code, I need to access the row.field object. Using the dictionary key does not seem to work as arcpy is interpreting this as a field name?

rows = arcpy.InsertCursor(inFeatures)
row = rows.newRow()
row.columnName = columnDict[columnName]


Is there any way to dynamically insert rows if you do not know the row.field name in your hardcode?

Thanks

Outcomes