Ok I think I’m close but need a little more help. I have a
table like the one attached. I’m trying to create a line segment from it
that goes from 22.473 to 27.346 but they are on separate lines. I need a
python script to calculate the to_measure from OBJECTID 1 equal to the
to_measure from OBJECTID2. Do you think that is possible?
You can iterate through each RID and update the to_MEAS field. Ex:
table = "Sample" ridList = [] with arcpy.da.SearchCursor(table, ["RID"]) as cursor: for row in cursor: ridList.append(row[0]) del cursor ridList = set(ridList) for RID in ridList: toMeasList = [] with arcpy.da.SearchCursor(table, ["RID", "to_MEAS"], "RID = '" + RID + "' ") as cursor: for row in cursor: toMeasList.append(row[1]) del cursor toMeasList.sort() with arcpy.da.UpdateCursor(table, ["to_MEAS"], "RID = '" + RID + "'") as cursor: for row in cursor: row[0] = toMeasList[-1] cursor.updateRow(row) del cursor
I get a 000539 : Error message from Python. It seems like it should work. At the end its taking the row[0] array and setting the toMeasList equal to it minus 1 record correct?
Says syntax error line 1 which is declaring the table correct?
Yes, you will need to update the 'table' variable with the feature class/table in the Table of Contents. Ex:
table = 'RoutingTable'
I did that, the table is called result. Does it have to be a certain type of table?
Can you zip and upload the table you are using?
Ok, made a little headway. It appears to not like the null values in the fields. When I: replace them with 0 then it does not error out at line 1 anymore. :It then give me the warming. "A Field name was not found or there were unbalanced quotation marks". I was not sure if this was due to line 21 or 15..
I'm jumping into this thread midstream, but I'm confused why this has anything to do with Calculate Field. You're running this in the Python window, not the field calculator, correct?
In any case, it looks like however you are calling CalculateField, it is set to VB not Python.