Calculating last record in feature class using ArcPy?

I want to automate a task in ArcGIS using arcpy. The task starts with creating points with 50 meter intervals along a line. Then use a loop to iterate and calculate values 50 meters from 0 to last point. The problem is I want to calculate the actual distance value of last point and I can't get last record. I try to use rowpt[-1] and use this sample but i don't know how to update the value. How can I get the last record?

import arcpy
arcpy.env.workspace = r"F:\test\env.gdb"
arcpy.env.overwriteOutput = True
line_lyr = "line"
pt_lyr =  "my_point"
interval = 50
arcpy.CreateFeatureclass_management(r"F:\test\env.gdb",pt_lyr,"POINT")
insertCursor = arcpy.da.InsertCursor(pt_lyr, ["SHAPE@XY"]) # this is the pre-existing pt feature class
with arcpy.da.SearchCursor(line_lyr, ['OID@','SHAPE@']) as searchCursor: # this is the line feature on which the points will be based
for row in searchCursor:
lengthLine = row.length # grab the length of the line feature, i'm using round() here to avoid weird rounding errors that prevent the numberOfPositions from being determined
if lengthLine % interval == 0:
numberOfPositions = int(lengthLine // interval) - 1
else:
numberOfPositions = int(lengthLine // interval)
if numberOfPositions >= 0:
distancezero = 0
xPoint = row.positionAlongLine(distancezero).firstPoint.X
yPoint = row.positionAlongLine(distancezero).firstPoint.Y
xy = (xPoint, yPoint)
insertCursor.insertRow([xy])
for i in range(numberOfPositions):
distance = (i + 1) * interval
xPoint = row.positionAlongLine(distance).firstPoint.X
yPoint = row.positionAlongLine(distance).firstPoint.Y
xy = (xPoint, yPoint)
insertCursor.insertRow([xy])
distanceend = lengthLine
xPoint = row.positionAlongLine(lengthLine).firstPoint.X
yPoint = row.positionAlongLine(lengthLine).firstPoint.Y
xy = (xPoint, yPoint)
insertCursor.insertRow([xy])
del insertCursor
with arcpy.da.UpdateCursor(pt_lyr,"Interval") as ptcursor:
number = 0
for rowpt in ptcursor:
rowpt = number
number = number + 50
ptcursor.updateRow(rowpt)
if rowpt[-1]== number-50:
rowpt[-1] = 100
....?
• The example you've linked allows you to modify the value in the last column for every record, not specifically just the last record. – Midavalo Oct 29 '16 at 18:54
• The way I'd try it is count the points for each line and record the last one in a dictionary along with the count (as part of the Insert Cursor). Then in your Update Cursor multiply that count by the interval and update that value into the corresponding point record. I can't test this right now though so may have overlooked some things. – Midavalo Oct 29 '16 at 18:59
• @Midavalo I Used arcpy.GetCount_management(point).getOutput(0) – BBG_GIS Oct 31 '16 at 13:41