Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

str object has no attribute append

$
0
0
I am trying to run an array where it loops through my "Cont_Buff" layer selects the first record, then selects all the culverts from the "Culvert_subset" layer that fall within that first record. Then takes the GWP value from the "Cont_Buff" layer and applies it to the WP field for all the selected culverts in the "Culvert_subset" layer. Once it has done this for the first record loop back and do the same for the second record in the "Cont_Buff" layer and so on.

However I have not been able to make it run past the loop because I am getting an 'str object has no attibute error'. My OBJECTID type is not string it is Long.
I've included the entire code block.
Code:

rows = arcpy.SearchCursor("Cont_Buff")
row = rows.next()

CUL_rows = arcpy.UpdateCursor("Culvert_subset")
CUL_row = rows.next()

while row:
    a = row.OBJECTID
    "OBJECTIDS".append(a)
    row = rows.next()

    #Set Count equal to the length of the array created in the while loop
    Count = len("OBJECTID")

#iterate through each individual feature by using a definition query
while Position < Count:
    query = "[OBJECTID] = " + "'" + OBJECTIDs[Position] + "'"
    "Cont_BUff".definitionQuery = query

    #center on feature
    df.panToExtent("Cont_Buff".getSelectedExtent())

    #Select all of the Culverts Cells within the active Site Boundary
    arcpy.SelectLayerByLocation_management("Culvert_subset","COMPLETELY_WITHIN","Cont_Buff",0,"NEW_SELECTION")

    #Set [WP] equal to Cont_Buff[GWP]
    hopper = '"' + str(OBJECTIDs[Position]) + '"'
    arcpy.CalculateField_management("Culvert_subset","WP",hopper,"VB","#")

I am not sure if this is even the correct way to do this seeing as how I cant get past the loop. Any suggestions?

Viewing all articles
Browse latest Browse all 2485

Trending Articles