AnsweredAssumed Answered

simple insert cursor issues

Question asked by Carusot42 on Feb 11, 2015
Latest reply on Feb 11, 2015 by blake.terhune

Hi folks,

 

I'm having some weird issues with an insert cursor.

 

Basically I have a dictionary, where each key corresponds to a list of orps. I want the inset cursor to iterate over each list in each dictionary key and insert a row with the corresponding values. Seems like it should be simple, but for some reason I keep getting an SQL error. I've used search and update cursors extensively, but haven't had a need for insert cursors before now, so any advice would be very greatly appreciated.

 

Here is the offending code:

 

match = {}

for o in well_owners:
    for p in orps_owners:
        if orps_owners[p] == well_owners[o]:
            match[o] = []
            match[o].append(p)

arcpy.CreateTable_management(h, "TABLE")
arcpy.AddField_management("TABLE", "DECWell_", "TEXT")
arcpy.AddField_management("TABLE", "match", "LONG")

for key in match:
    rows = arcpy.da.InsertCursor("TABLE", ["DECWell_", "match"])
    for s in match[key]:
        rows.insertRow((wellnum[key], s))
    del rows

 

where well_owners and orps_owners are dictionaries of last names of owners and wellnum is a dictionary of unique identifiers to be written to the table.

 

Thanks in advance.

Outcomes