<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: using multiple cursors in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125380#M9763</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Chris Lowrie
#Refactoring 1
#Bluespace Report and Row Creation Script


#import the necessary bits
import arcpy, math, os


#Get the points to use
table = arcpy.GetParameterAsText(0)
name = arcpy.GetParameterAsText(1)
fields = ["Latitude","Longitude", "HMS", "Day"]


date_fld = "DateTimeS"
arcpy.env.workspace = "C:\Users\project-user\Desktop\BlueSpace"
f = open(name + "_Bluespace_report.txt", "w")
fid_lst = []






#Calculate the distance between two points near Wellington, New Zealand
#Can be made more accurate if desired
def calculate_distance(x0, x1, y0, y1):
&amp;nbsp; #111,200 meters per degree of latitude
&amp;nbsp; #67,097 meters per degree of longitude at 41 degrees latitude (Wellington)
&amp;nbsp; dx = abs(x1-x0)*67097
&amp;nbsp; dy = abs(y1-y0)*111200
&amp;nbsp; distance = math.sqrt(math.pow(dx,2) + math.pow(dy,2))
&amp;nbsp; return distance




def fill_gap(row, rows_to_add):
&amp;nbsp; edit.startOperation()
&amp;nbsp; insert_cursor = arcpy.da.InsertCursor(table, fields)
&amp;nbsp; f.write("Insert")
&amp;nbsp; i = 1
&amp;nbsp; f.write(str(rows_to_add))
&amp;nbsp; while i &amp;lt; rows_to_add+1:
&amp;nbsp; to_insert = (row[0], row[1], row[2]+5*i, row[3])
&amp;nbsp; insert_cursor.insertRow(to_insert)
&amp;nbsp; i += 1
&amp;nbsp; edit.stopOperation()




def process_table():
&amp;nbsp; #Creates an update cursor
&amp;nbsp; rows = arcpy.da.SearchCursor(table, fields)


&amp;nbsp; prev_t = 0
&amp;nbsp; prev_x = 0
&amp;nbsp; prev_y = 0
&amp;nbsp; total_gaps = 0
&amp;nbsp; over_1 = 0
&amp;nbsp; over_5 = 0
&amp;nbsp; over_100_meters = 0
&amp;nbsp; delta_t = 0


&amp;nbsp; first = True
&amp;nbsp; dic = {}
&amp;nbsp; extremes_lst = []
&amp;nbsp; fid_lst = []

&amp;nbsp; #Iterator
&amp;nbsp; for row in rows:
&amp;nbsp; #the time
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hms = row[2]

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #If not the first pass
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first != True:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if hms - prev_t &amp;gt; 5:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distance = calculate_distance(prev_x, row[1], prev_y, row[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delta_t = hms-prev_t
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(str(delta_t)+"\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delta_t_str = str(delta_t/60) + " minutes " + str(delta_t%60) + " seconds "
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows_to_add = delta_t/5 - 1

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fid_lst.append(prev_row)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fill_gap(prev_row, rows_to_add) 


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; first = False
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prev_t = hms
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prev_x = row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prev_y = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prev_row = row








workspace = os.path.dirname(table)
edit = arcpy.da.Editor(workspace)
edit.startEditing(False, False)
process_table()
edit.stopEditing(True)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, much needed formatting tutorial.&amp;nbsp; It now adds rows with the values that I want, but I'd like them to be added directly beneath the row I am sending to fill_gap.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 07:08:47 GMT</pubDate>
    <dc:creator>ChrisLowrie</dc:creator>
    <dc:date>2021-12-11T07:08:47Z</dc:date>
    <item>
      <title>using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125374#M9757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to be able to search through a set of data points, each with a time stamp, and insert rows between two data points that are more than 5 seconds apart.&amp;nbsp; The first pass with the cursor is used to turn the time stamp into an integer so that I can work with it, but after that it won't reset and attempts to open another cursor, even after deleting the first, don't work.&amp;nbsp; Any ideas of how to do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Apr 2016 17:02:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125374#M9757</guid>
      <dc:creator>ChrisLowrie</dc:creator>
      <dc:date>2016-04-15T17:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125375#M9758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is good practice to only attempt one pass with an update cursor to completion, then after that use a new cursor to do any inserts.&amp;nbsp; You do not have to create a new field to work with the time stamp as an integer, and could instead do this within a python dictionary or list in memory, so that you would use a search cursor to load it all into memory, analyze it there, then use an insert cursor to create the new points.&amp;nbsp; That way no conflict between cursors would occur.&amp;nbsp; But without more info I cannot propose any code.&amp;nbsp; Post the code you are attempting so we have some idea of what you are actually trying.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Apr 2016 17:40:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125375#M9758</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2016-04-15T17:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125376#M9759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;a few lines of the table would also be interesting as well.&amp;nbsp; Given your description, it doesn't appear that you will be joining the table back to anything, since the row insertion would foul up the current ID system.&amp;nbsp; options abound&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Apr 2016 18:13:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125376#M9759</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-15T18:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125377#M9760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I have so far.&amp;nbsp; It creates a report of where the gaps are, but I can't get a second cursor to exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE height="1666" jive-data-cell="{&amp;quot;color&amp;quot;:&amp;quot;#606060&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;start&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;NaN&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;transparent&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif&amp;quot;,&amp;quot;verticalAlign&amp;quot;:&amp;quot;baseline&amp;quot;}" jive-data-header="{&amp;quot;color&amp;quot;:&amp;quot;#505050&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#F2F2F2&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;left&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;6&amp;quot;}" style="width: 1277px; height: 1631px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;def process_table():&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#create the hms and day fields, create lists and totals for the summaries&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#Creates a cursor to iterate through the table, grabs the field we are interested in&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;rows = arcpy.UpdateCursor(table)&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#Create initial conditions for the previous row, and a bool for the first iteration&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;prev_t = 0&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;prev_x = 0&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;prev_y = 0&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;prev_day = ""&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;first = True&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;dic = {}&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;total_gaps = 0&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;over_2 = 0&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;over_5 = 0&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;over_100_meters = 0&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;delta_t = 0&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;extremes_lst = []&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;for row in rows:&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;full_date = row.getValue(date_fld) &lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#Get the date and time&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;date_lst = full_date.split("T")&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#Split into date and time&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;row.setValue("Day", str(date_lst[0]))&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#Set the date to be the first half&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;full_time = date_lst[1]&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#Full time is the second&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;time_lst = full_time.split(":")&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#Split the time&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;hr = int(time_lst[0])&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#into hours&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;mn = int(time_lst[1])&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#into minutes&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;sec = int(time_lst[2][0:2])&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#into seconds, cut off the "Z"&lt;/TD&gt;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lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if hms - prev_t&amp;gt; 5:&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;distance = calculate_distance(prev_x, row.getValue("Longitude"), prev_y, row.getValue("Latitude"))&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;rows_to_add = (hms-prev_t)/5 - 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;total_gaps += rows_to_add&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;delta_t = str((hms-prev_t)/60) + " minutes and " + str((hms-prev_t)%60) + " seconds"&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;to_add = (rows_to_add, delta_t, distance)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;fid_lst.append(&amp;nbsp; (int(row.getValue("FID"))-1,&amp;nbsp; rows_to_add,&amp;nbsp; (prev_x, row.getValue("Longitude")),&amp;nbsp;&amp;nbsp;&amp;nbsp; (prev_y, row.getValue("Latitude")),&amp;nbsp; distance)&amp;nbsp; ) &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#0: Row's FID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#1: Number of rows to add&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#2: Tuple of x's&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#3: Tuple of y's&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#4: Distance&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&l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;prev_day = row.getValue("Day")&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;return extremes_lst, dic, over_2, over_5, over_100_meters, total_gaps, fid_lst&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From this I've been trying to use fid_lst to find where to insert rows.&amp;nbsp; Something like:&lt;/P&gt;&lt;P&gt;insert = arcpy.InsertCursor(table)&lt;/P&gt;&lt;P&gt;for row in insert:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.getValue("FID") == fid_lst[0][0]:&amp;nbsp; #the fid&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows_to_add = fid_lst[0][1]&amp;nbsp;&amp;nbsp; #the rows to add&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for x in range(1, rows_to_add + 1) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #add new rows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fid_lst.pop(0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in fid_lst:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i[0] += rows_to_add&amp;nbsp;&amp;nbsp;&amp;nbsp; #accounts for the shift in FID from adding the new rows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice is appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2016 19:02:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125377#M9760</guid>
      <dc:creator>ChrisLowrie</dc:creator>
      <dc:date>2016-04-21T19:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125378#M9761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I actually just went back through and researched the arcpy.da.InsertCursor object.&amp;nbsp; It inserts rows now, but is there a way to insert the row in the middle of the table instead of at the end?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2016 21:29:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125378#M9761</guid>
      <dc:creator>ChrisLowrie</dc:creator>
      <dc:date>2016-04-21T21:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125379#M9762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;first &lt;A href="https://community.esri.com/migration-blogpost/55181"&gt;Code Formatting... the basics++&lt;/A&gt; &lt;/P&gt;&lt;P&gt;too hard to dissect what is going on&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2016 21:32:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125379#M9762</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-21T21:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125380#M9763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Chris Lowrie
#Refactoring 1
#Bluespace Report and Row Creation Script


#import the necessary bits
import arcpy, math, os


#Get the points to use
table = arcpy.GetParameterAsText(0)
name = arcpy.GetParameterAsText(1)
fields = ["Latitude","Longitude", "HMS", "Day"]


date_fld = "DateTimeS"
arcpy.env.workspace = "C:\Users\project-user\Desktop\BlueSpace"
f = open(name + "_Bluespace_report.txt", "w")
fid_lst = []






#Calculate the distance between two points near Wellington, New Zealand
#Can be made more accurate if desired
def calculate_distance(x0, x1, y0, y1):
&amp;nbsp; #111,200 meters per degree of latitude
&amp;nbsp; #67,097 meters per degree of longitude at 41 degrees latitude (Wellington)
&amp;nbsp; dx = abs(x1-x0)*67097
&amp;nbsp; dy = abs(y1-y0)*111200
&amp;nbsp; distance = math.sqrt(math.pow(dx,2) + math.pow(dy,2))
&amp;nbsp; return distance




def fill_gap(row, rows_to_add):
&amp;nbsp; edit.startOperation()
&amp;nbsp; insert_cursor = arcpy.da.InsertCursor(table, fields)
&amp;nbsp; f.write("Insert")
&amp;nbsp; i = 1
&amp;nbsp; f.write(str(rows_to_add))
&amp;nbsp; while i &amp;lt; rows_to_add+1:
&amp;nbsp; to_insert = (row[0], row[1], row[2]+5*i, row[3])
&amp;nbsp; insert_cursor.insertRow(to_insert)
&amp;nbsp; i += 1
&amp;nbsp; edit.stopOperation()




def process_table():
&amp;nbsp; #Creates an update cursor
&amp;nbsp; rows = arcpy.da.SearchCursor(table, fields)


&amp;nbsp; prev_t = 0
&amp;nbsp; prev_x = 0
&amp;nbsp; prev_y = 0
&amp;nbsp; total_gaps = 0
&amp;nbsp; over_1 = 0
&amp;nbsp; over_5 = 0
&amp;nbsp; over_100_meters = 0
&amp;nbsp; delta_t = 0


&amp;nbsp; first = True
&amp;nbsp; dic = {}
&amp;nbsp; extremes_lst = []
&amp;nbsp; fid_lst = []

&amp;nbsp; #Iterator
&amp;nbsp; for row in rows:
&amp;nbsp; #the time
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hms = row[2]

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #If not the first pass
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first != True:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if hms - prev_t &amp;gt; 5:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distance = calculate_distance(prev_x, row[1], prev_y, row[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delta_t = hms-prev_t
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(str(delta_t)+"\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delta_t_str = str(delta_t/60) + " minutes " + str(delta_t%60) + " seconds "
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows_to_add = delta_t/5 - 1

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fid_lst.append(prev_row)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fill_gap(prev_row, rows_to_add) 


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; first = False
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prev_t = hms
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prev_x = row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prev_y = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prev_row = row








workspace = os.path.dirname(table)
edit = arcpy.da.Editor(workspace)
edit.startEditing(False, False)
process_table()
edit.stopEditing(True)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, much needed formatting tutorial.&amp;nbsp; It now adds rows with the values that I want, but I'd like them to be added directly beneath the row I am sending to fill_gap.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:08:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125380#M9763</guid>
      <dc:creator>ChrisLowrie</dc:creator>
      <dc:date>2021-12-11T07:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125381#M9764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should also change any search or update cursor to the da version, since they are 10 times faster than the old style Python cursors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately the answer is no, you can't insert new records between existing records within an existing feature class.&amp;nbsp; ObjectIDs are issued consecutively and cannot be shifted and if deleted they cannot be reused.&amp;nbsp; The only safe way to get the records organized based on attributes is by using the Sort tool, which will create a new feature class.&amp;nbsp; This tool resets all ObjectIDs in the new feature class to fit the new order and removes any ObjectID gaps that were created by deleted records.&amp;nbsp; You then would replace the original FC with the new sorted FC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you really insist on not creating a new feature class and are willing to put all of your data at risk, then after inserting every record, you could load everything to a sorted dictionary or list and then use an update cursor to overwrite every record, setting all editable fields with the data of the appropriate record that fits the order you want.&amp;nbsp; ObjectID gaps from deleted records would remain gaps after using this approach, but the records would be reordered without creating a new FC.&amp;nbsp; Aside from the risk to your data, if you have GlobalIDs or other non-editable fields that don't reset based on the changes you make then you probably don't want to do this, since there is no way their field values could be kept with the original record they were associated with.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2016 21:49:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125381#M9764</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2016-04-21T21:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125382#M9765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chris your formatting is still off.&amp;nbsp; your fill_gap def has no indentation in the while loop, so it won't work and your spacing changes from 2 to 4 spaces within the function.&amp;nbsp; Can you confirm that the above is what you are working with or is it just a bad copy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2016 21:51:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125382#M9765</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-21T21:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125383#M9766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe one of the db gurus can step in here, but I think there is no concept of ordering or gaps in a database table.&lt;/P&gt;&lt;P&gt;All inserts will be appended to the end of the table.&lt;/P&gt;&lt;P&gt;The only way to get them to be ordered is to reprocess and recreate the data.&lt;/P&gt;&lt;P&gt;You can obviously impose an ordering on your view of the data (like sorting the table in ArcMap), but this is doing nothing to the actual order on disc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Apr 2016 08:17:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125383#M9766</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-04-22T08:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125384#M9767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In ArcGIS databases designed by Esri, a concept of order and gaps is in a database has been created by the automatic creation and maintenance of the FID/ObjectID, which uniquely identifies each record at the time it is created.&amp;nbsp; New numbers are always appended to the end of the number order and any deleted record creates a gap in the FID/ObjectID numbers that cannot be filled, without transferring the data into a new table/FC.&amp;nbsp; Search cursors do in fact read the records in the FID/ObjectID order by default, which is the fastest order based on how the records are indexed and stored.&amp;nbsp; Cursors can be sorted, but all other record orders can only be read at the cost of a substantial performance hit when read directly from disk.&amp;nbsp; Most record sorting of tables initially is read in ObjectID order and is only resorted in memory through things like a tableview before being presented to the user to overcome this performance hit.&amp;nbsp; No other automatically maintained record numbering is associated with the Esri databases.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Apr 2016 14:48:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125384#M9767</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2016-04-22T14:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125385#M9768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Richard Fairhurst wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Search cursors do in fact read the records in the FID/ObjectID order by default, ....&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I don't recall seeing any Esri documentation that explicitly states ArcGIS or ArcPy cursors include a default ORDER BY clause on the FID/OID field for any kind of data store.&amp;nbsp; If you have found some, I am interested in the link.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Apr 2016 16:45:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125385#M9768</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-04-22T16:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125386#M9769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only documentation about the FID/ObjectID I have seen is &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//005s0000000z000000"&gt;&lt;SPAN style="color: #0066cc; text-decoration: underline;"&gt;here&lt;/SPAN&gt;&lt;/A&gt;.&amp;nbsp; It is not a technical discussion of the implementation of the ObjectID, nor is it an exhaustive discussion of the implications of the ObjectID for a programmer, and it in no way contradicts the behavior I am reporting that I have repeatedly observed for a Search Cursor.&amp;nbsp; Few things are fully documented for programmers about the internal mechanisms Esri has implemented, and most everything that goes beyond the exposed interfaces that may have critical implications for the programmer has to be deduced through experimentation and testing and only gets documented through the forum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not have a document reference for this behavior.&amp;nbsp; However, having used Search Cursors for years on a daily basis it has been empirically established to a degree that I am certain that the FID/ObjectID is the established default order of the Search Cursor.&amp;nbsp; Clues that Esri databases with FID/ObjectIDs actively maintain some kind of internal order involving the FID/ObjectID for performance include the fact that FID/ObjectID fields are always automatically indexed by the system.&amp;nbsp; Search Cursor record counting is accurate and predictable and always ordered by the FID/ObjectID when used without any Order By parameter by the user.&amp;nbsp; FID/ObjectID lists returned by methods that access record Selection Sets always list the FID/ObjectID values in order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will acknowledge that Update Cursors have sometimes shown erratic behavior as far as reading records, especially if combined with a parallel Insert Cursor operation.&amp;nbsp; Update Cursors have been known to read the same record two or more times during a single pass of the cursor, usually reading the same record again immediately after an updateRow operation during consecutive for loop passes, but this is a bug as far as I am concerned and is a behavior that has never been documented by Esri or explained.&amp;nbsp; That Update Cursor behavior is a source of complaint on the forum since it screws up all record counting procedures with an Update Cursor and no one has been able to make sense of it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Apr 2016 18:08:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125386#M9769</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2016-04-22T18:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125387#M9770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Back early in ArcGIS time (the summer of 2000) I was warned directly to never never assume record order in ArcGIS like we used to in INFO (a brutally simple [and very fast) database that composed the database part of "Arc/INFO").&amp;nbsp; I was told different data formats (notably RDBMS data sources) may return data in an unpredictable order due to the RDBMS doing parallel processing that Esri does not control.&amp;nbsp; ORDER BY is supported for all geodatabase data sources. I also have made use of sorting results coming out of a search cursor as in : sorted(arcpy.da.SearchCursor(tbl, field)).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Apr 2016 02:40:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125387#M9770</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2016-04-23T02:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125388#M9771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I only edit File geodatabase with cursors for performance reasons and download SDE data to that format for all geoprocessing.&amp;nbsp; The predictable order that the file geodatabase format provides only leads me to say that I have one more reason to continue doing what I do.&amp;nbsp; Under any circumstances, ObjectIDs do represent the order that records are created in a geodatabase and cannot be reused once issued or deleted without risking database corruption, and no other order is represented or maintained within the data automatically in ArcGIS without a custom written program.&amp;nbsp; When working with personal geodatbases I have seen the effect when a user corrupted the order and uniqueness of the ObjectID field through an Access update query run outside of ArcGIS, but nothing works correctly in ArcGIS if that happens.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Apr 2016 06:48:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125388#M9771</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2016-04-23T06:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125389#M9772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This whole thread has me seeing issues with 'bits' of the process getting parsed out into separate blocks of discontiguous memory or storage location on disk.&amp;nbsp; This will surely slow down the whole process.&amp;nbsp; I must agree with finishing one task, consolidating access in memory or on disk, then proceeding to the next task as being the best approach rather than to shuffle cursors within cursors.&amp;nbsp; Numpy has an 'iscontiguous' property when working with data arrays, which I use prior to running a second process... if it isn't, I consolidate before continuing.&amp;nbsp; Do File geodatabases or cursors in general, not employ such a protocol?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Apr 2016 09:49:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125389#M9772</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-23T09:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125390#M9773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Richard, thanks for providing a link.&amp;nbsp; Although the text hasn't appeared to change from ArcGIS 10.1 to ArcGIS 10.4, there is a corresponding web page in the new online documentation:&amp;nbsp; &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/manage-data/tables/fundamentals-of-objectid-fields.htm"&gt;Fundamentals of ObjectID fields&lt;/A&gt;.&amp;nbsp; Unfortunately, but not completely surprising, that page on ObjectIDs doesn't mention anything about sorted-ness or ordered-ness.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;A href="https://desktop.arcgis.com/en/arcobjects/latest/net/a2596185-823b-4de3-9831-7842fb6100fb.htm#About"&gt;ArcObjects Help for .NET Developers &lt;/A&gt;has a &lt;A href="https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#bef38cda-6aa0-42f0-8346-13030f84b9c8.htm"&gt;Geodatabase &lt;/A&gt;library page that I think sheds some light on the this topic:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;The Geodatabase library provides the application programming interface (API) for the geodatabase. The geodatabase is a repository of geographic data built on standard industry relational and object relational database technology. The objects in the library provide a unified programming model for all supported data sources in ArcGIS. The Geodatabase library defines many of the interfaces that are implemented by data source providers higher in the architecture.&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;A table has one or more columns, referred to as fields, and contains an unordered collection of rows. For each field, each row has exactly one value in the data type of the field.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For databases, at least relational databases, tables represent unordered collections of rows.&amp;nbsp; That said, tables can be ordered to some extent by adding certain types of indexes, like a clustered index in SQL Server, but that is an implementation matter addressing performance and not a design principle of ordered-ness.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above quote, the Geodatabase library page is talking about the API and not the file geodatabase storage itself.&amp;nbsp; It seems reasonable enough that Esri could have implemented a cluster-like index on ObjectID, it would explain a fair amount of behavior you see, but I have never seen or found documentation that speaks to the issue directly.&amp;nbsp; Even if that is the case, it doesn't change the fact that a user accesses the contents of a file geodatabase through the API in one form or another, and that API doesn't guarantee any order on the rows of a table, unless using ORDER BY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you have seen empirically with ObjectID ordering and Search Cursors doesn't surprise me, because I do think there is a cluster-like index on ObjectID in file geodatabases, but what you have seen with Update Cursors also doesn't surprise me because order isn't guaranteed in the Geodatabase API unless ORDER BY clauses are present.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Apr 2016 15:09:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125390#M9773</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-04-23T15:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125391#M9774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do not base many processes on the order of ObjectIDs, but everything I see says that Order By on any other column is slower, which probably has more to do with the fact the ObjectID is always the first column in a geodatabase than any internal storage of the records relative to each other.&amp;nbsp; It is guaranteed that a sort on the 40th column in a database will be much slower when read from disk using Order By than an Order By on the ObjectID in the first column.&amp;nbsp; Most sorted processing I do is through in memory processing of lists or dictionaries, or through Summary Statistics outputs that position the sorted fields at the beginning of the schema.&amp;nbsp; Order By also should never be done on a column that is not indexed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In any event, order can play an important part of any process (drawing order, analysis, etc), and if I reorganize a database using the Sort tool or create a Summary Statistics table to make the ObjectID column reflect that order it absolutely does benefit performance of tasks that use that order.&amp;nbsp; Again this may be more because the ObjectID is always the first column in the schema, it is always indexed for quick access, and it has a known field type all of which optimize it for the quickest access and processing.&amp;nbsp; Constantly processing an SQL Order By on a random field column in the database that the user may have failed to index that has to repeatedly determine its field position and value type each time you want to run a sort algorithm is bound to be slower.&amp;nbsp; Column position in a database is not random and the first column is the fastest column to access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The documentation makes this a black box, so all we can argue is whether or not empirically it is useless to get an ordered ObjectID or not.&amp;nbsp; I say it is useful where quick access to ordered records is essential based on everything I have experienced, whether or not I can explain why that is occurring to your satisfaction.&amp;nbsp; I care far more about giving advice on the practical effect of doing or not something than I do about the actual internal mechanism used to achieve that effect in a Black Box that I cannot access.&amp;nbsp; So if my guesses on the Black Box are wrong, but the practical outcome is real nonetheless, my advice on the forum will always be of more value for the second than the first, and I am satisfied with that.&amp;nbsp; I also do not advise anyone to constantly recreate their feature class every time they want to insert a single record into the middle of the ObjectID order, since that is very inefficient, but periodically optimizing for order can be useful if you don't rely on the ObjectID representing the same record each time you access the database.&amp;nbsp; I actually don't sort most of my data, because in most cases the value of having an ObjectID in my master database consistently return the same record every time I access it is more valuable to me than having it represent a constantly changing order. Also the design of the ObjectID is primarily intended to support consistent access to the same record in a feature class, although that is only reliable if a feature class that has never been moved or recreated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Apr 2016 18:44:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125391#M9774</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2016-04-23T18:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple cursors</title>
      <link>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125392#M9775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I didn't expect my few lines of comment to generate such a rich &amp;amp; long discussion on the underlying nature of the data tables.&lt;/P&gt;&lt;P&gt;Curtis, I remember Info well. Did a lot with that in the depths of info processing. Yes, Info ran on ordered lists. So was not a rdms in any modern sense. Do you recall odd / even record processing.....?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Apr 2016 12:07:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multiple-cursors/m-p/125392#M9775</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-04-25T12:07:51Z</dc:date>
    </item>
  </channel>
</rss>

