AnsweredAssumed Answered

UpdateCursor list indices must be intergers, not str

Question asked by CCweedcontrol on Nov 25, 2015
Latest reply on Nov 25, 2015 by dkwiens

currently have a code that i would like to update a certain field based off of two other fields but i am getting a error.

 

Error:TypeError: list indices must be integers, not str.

on line : row[7] = (sourceFieldsList['SiteStreet_1'] + " " + sourceFieldsList['StreetType_1'])

 

The only difference in the fields is that some have different lengths, the fields are 'String' fields so i am not sure what's going on other then the lengths. Do the fields have to be the same lengths?

 

Any help would be great, thanks!

# define the field list from the spatial join
    sourceFieldsList = ["TARGET_FID", poly,"SiteAddress",'SiteNum_1', 'SiteStreet_1','SiteNumSfx_1','Predir_1','SiteStreet_1', 'Postdir_1', 'SiteCity_1', 'SiteZIP_1', 'OwnerName_1','StreetType_1']    #

    # define the field list to the original points
    updateFieldsList = ["OID@", Pnt,"SiteAddres", 'SiteNum', 'StreetName', 'SiteNumSfx','Predir','SiteStreet', 'Postdir', 'SiteCity', 'SiteZip', 'OwnerName' 'StreetType']
    
    # Start an edit session. Must provide the workspace.    
    edit = arcpy.da.Editor(arcpy.env.workspace)    
  
    # Edit session is started without an undo/redo stack for versioned data    
    #  (for second argument, use False for unversioned data)    
    edit.startEditing(True)    
  
    # Start an edit operation    
    edit.startOperation()    
    manualFields =  ["FacltyType","GIS_STEW", "StructType", "Verified", "Status", "StructCat", "APA_CODE",'StreetName'] #]
           
    with arcpy.da.UpdateCursor(pointLayer, manualFields) as rows:       
        for row in rows:       
            row[0] = ("Single Family Home")
            row[1] = ("Canyon")
            row[2] = ("Primary, Private")           
            row[3] = ("Yes, GRM, TA")           
            row[4] = ("LM")
            row[5] = ("Residential")           
            row[6] = ("1110")
            row[7] = (sourceFieldsList['SiteStreet_1'] + " " + sourceFieldsList['StreetType_1'])
            rows.updateRow(row)

Outcomes