1
import arcpy
rows = arcpy.SearchCursor("E:/Arcgis/lx.gdb/testSUBorigin", "", "", "",  "VEHICLEID A; TIME A") 
arcpy.AddField_management("testSUBorigin", "SUB", "TEXT")
cursor = arcpy.SearchCursor("E:/Arcgis/lx.gdb/testSUBgetondropoffshp") 
for line in cursor:
    for row in rows: 
        if (line.VEHICLEID == row.VEHICLEID) and (line.TIME != row.TIME):
           row.SUB = "36_1"
         else:
           line.next()

Runtime error Traceback (most recent call last): File "", line 3, in File "d:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 3243, in AddField raise e ExecuteError: ERROR 000732: Input Table: Dataset testSUBorigin does not exist or is not supported

I want to add Subtrack point name attribute according to the get_on and drop_off points,But I don't know the mistake,and I don't know whether the idea is true.I sincerely hope someone do the similar work can help me.

2
  • 2
    You should copy your code and format it instead of posting a picture of it Mar 28, 2018 at 3:12
  • For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code nicely.
    – PolyGeo
    Mar 28, 2018 at 3:43

1 Answer 1

2

You have an assignment in your if line rather than a logical comparison.

Change the line that says:

if (line.VEHICLEID = row.VEHICLEID) and (line.TIME != row.TIME): 

to:

if (line.VEHICLEID == row.VEHICLEID) and (line.TIME != row.TIME): 

Further, if you're using ArcGIS 10.1 or above, it's recommended that you use the arcpy.da.SearchCursor, rather than arcpy.SearchCursor

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.