More

What is the most efficient way to get the values of a previous row in a table using ArcPy?


I am very new to ArcGis and I would like to get a specific value of the previous row in a table.

I found this question here on gis.stackexchange.com and experimented a little bit. However, I found out this modified version:

Pre-Logic Script Code:

import arcpy def getLastASTDate(tableName): return [r[0] for r in arcpy.da.SearchCursor(tableName, "date")][-1]

test =

getLastASTDate("name_of_table")

Unfortunately this version doesn't work and is -- in my opinion -- very inefficient. Do you know any better solutions?


You want to be using dictionaries to answer this question. The answer in How to access adjacent rows will help you.

To be able to answer your question you need to be supplying the row ID of the row you want to find the previous row from, my question is how are you defining that?