one of my staff members is having trouble accessing GeoNet and has this question:Laura Conner
I am trying to get several routes to combine in to one route. I have created the sub routs and are now trying to combine them with a python script.
The error I am currently running in to is AttributeError: 'list' object has no attribute 'setValue' on the line s.setValue(RouteName, cr). From what I can tell this means object s a list can’t handle the setValue method. Yet from all the examples I have seen I am using the same syntax as the examples given by esri on the arcpy.da.UpdateCursor documentation and other examples. the only difference I can see is variables. Even when try as one forum suggested: s[0].setValue(RouteName, cr) it gives AttributeError: 'str' object has no attribute 'setValue for the respective line.
How do I get my script working to update both fields of the feature class up date?
# internal script for concating subroutes in to larger routs
rln = ["1N-1","1N-2"]# list of sub route names to be concatinated
r=0 # last highest value sarts at 0
fc = r'C:\Users\lconner\OneDrive - Macon Water Authority\projects\curbs and gutters in the county\Swepper_Routes_2\Swepper_Routes_2_1.gdb\Route1\Stops1'
#feature class the concatination is to be preformed on
rsn =['RouteName','Sequence'] #list of feilds needed route name and sequence
cr= '1NCB' # name of concatinated route
# sn = sequence number the stop will have in the conacted route
# s= stops in the subroute
for e in rln:
#get records where route name feild = e
with arcpy.da.UpdateCursor(fc,['RouteName','Sequence']) as sl:
# str('RouteName' == e)
# right sequence number to list =snl
# order list
for s in sl:
sn=r=r+1
# wright sn to atrabute of the main route
s[1]= sn
s[0]= cr
s.setValue(RouteName, cr)
s.setValue(Sequence, sn)
sl.updateRow(s)
del sl
more details:
Arc Pro: 2.6
Run in python widow in the respective project
Windows: 10 pro 64 bit