Selecting just the first row from a search cursorSearch cursor stops selecting after two iterationsUsing arcpy.da.InsertCursor to insert entire row that is fetched from search cursor?Insert cursor for first row in unique value set arcpyOutput the Search Cursor as a stringCursor update row operatorUsing Search/Update Cursor?Stratified random point sampling in PythonComparing value with value from the next rowDeleting row using ArcPy cursor?Switching from Nested Search Cursors to Dictionaries
What's the output of a record cartridge playing an out-of-speed record
How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?
How to write a macro that is braces sensitive?
Maximum likelihood parameters deviate from posterior distributions
What would happen to a modern skyscraper if it rains micro blackholes?
can i play a electric guitar through a bass amp?
What's the point of deactivating Num Lock on login screens?
Can I ask the recruiters in my resume to put the reason why I am rejected?
Why did Neo believe he could trust the machine when he asked for peace?
Can divisibility rules for digits be generalized to sum of digits
The use of multiple foreign keys on same column in SQL Server
How can bays and straits be determined in a procedurally generated map?
LaTeX closing $ signs makes cursor jump
What are these boxed doors outside store fronts in New York?
What does "Puller Prush Person" mean?
Dragon forelimb placement
Email Account under attack (really) - anything I can do?
What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)
How to find program name(s) of an installed package?
Do VLANs within a subnet need to have their own subnet for router on a stick?
Which models of the Boeing 737 are still in production?
Today is the Center
Writing rule stating superpower from different root cause is bad writing
How old can references or sources in a thesis be?
Selecting just the first row from a search cursor
Search cursor stops selecting after two iterationsUsing arcpy.da.InsertCursor to insert entire row that is fetched from search cursor?Insert cursor for first row in unique value set arcpyOutput the Search Cursor as a stringCursor update row operatorUsing Search/Update Cursor?Stratified random point sampling in PythonComparing value with value from the next rowDeleting row using ArcPy cursor?Switching from Nested Search Cursors to Dictionaries
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Currently I am trying to select the top row of a feature class which is sorted using a Count field. I then would like to run the script a second time but the result will then be the second row of the table. I currently have the script below.
#import arcpy module
import arcpy
from arcpy import env
env.workspace = "D:\Trimble.gdb"
#allow overwrites
arcpy.env.overwriteOutput = True
#print list of feature classes
featList = arcpy.ListFeatureClasses()
print featList
#cheack if Messages and Township spatial join has been made
for feat in featList:
if arcpy.Exists("TWP_Messages"):
print "Township and Messages Without Roads joined already"
print ""
break
else:
#create spatial join between Messages and Townships
target_features = "D:\Trimble.gdb\TWP"
join_features = "D:\Trimble.gdb\Messages"
out_feature = "D:\Trimble.gdb\TWP_Messages"
arcpy.SpatialJoin_analysis(target_features, join_features, out_feature)
#sort Join_Count field by Descending
arcpy.Sort_management("TWP_Messages", "TWP_Messages_Sort", [["Count_", "DESCENDING"]])
print arcpy.GetMessage(2)
messageSort = "D:\Trimble.gdb\TWP_Messages_Sort"
#add field to messages sort feature to describe if item has been deleted already
arcpy.AddField_management(messageSort, "Downloaded", "TEXT")
#update all Downloaded fields to No
with arcpy.da.UpdateCursor(messageSort, "Downloaded") as cursor:
for row in cursor:
row[0] = "No"
cursor.updateRow(row)
del row
del cursor
messageSorted = "D:\Trimble.gdb\TWP_Messages_Sort"
i = 0
with arcpy.da.SearchCursor(messageSorted, ["DESCRIPTOR", "Count_"]) as cursor:
for row in cursor:
if row[1] != i:
print("Descriptor: Count: ".format(row[0], row[1]))
i = row[1]
name = row[0]
with arcpy.da.UpdateCursor(messageSorted, ["Count_", "Downloaded"]) as curs:
for line in curs:
if line[0] == i:
line[1] = "Yes"
curs.updateRow(line)
break
print name
Currently it is rewriting the fields it updates (Downloaded) every time and does not remember where it left off. Obviously the break is causing a problem here too.
I thought about making a table that updates each item that has previously been selected so then the search could check there and continue on to the next needed row. Unsure how to implement that too.
arcpy
add a comment |
Currently I am trying to select the top row of a feature class which is sorted using a Count field. I then would like to run the script a second time but the result will then be the second row of the table. I currently have the script below.
#import arcpy module
import arcpy
from arcpy import env
env.workspace = "D:\Trimble.gdb"
#allow overwrites
arcpy.env.overwriteOutput = True
#print list of feature classes
featList = arcpy.ListFeatureClasses()
print featList
#cheack if Messages and Township spatial join has been made
for feat in featList:
if arcpy.Exists("TWP_Messages"):
print "Township and Messages Without Roads joined already"
print ""
break
else:
#create spatial join between Messages and Townships
target_features = "D:\Trimble.gdb\TWP"
join_features = "D:\Trimble.gdb\Messages"
out_feature = "D:\Trimble.gdb\TWP_Messages"
arcpy.SpatialJoin_analysis(target_features, join_features, out_feature)
#sort Join_Count field by Descending
arcpy.Sort_management("TWP_Messages", "TWP_Messages_Sort", [["Count_", "DESCENDING"]])
print arcpy.GetMessage(2)
messageSort = "D:\Trimble.gdb\TWP_Messages_Sort"
#add field to messages sort feature to describe if item has been deleted already
arcpy.AddField_management(messageSort, "Downloaded", "TEXT")
#update all Downloaded fields to No
with arcpy.da.UpdateCursor(messageSort, "Downloaded") as cursor:
for row in cursor:
row[0] = "No"
cursor.updateRow(row)
del row
del cursor
messageSorted = "D:\Trimble.gdb\TWP_Messages_Sort"
i = 0
with arcpy.da.SearchCursor(messageSorted, ["DESCRIPTOR", "Count_"]) as cursor:
for row in cursor:
if row[1] != i:
print("Descriptor: Count: ".format(row[0], row[1]))
i = row[1]
name = row[0]
with arcpy.da.UpdateCursor(messageSorted, ["Count_", "Downloaded"]) as curs:
for line in curs:
if line[0] == i:
line[1] = "Yes"
curs.updateRow(line)
break
print name
Currently it is rewriting the fields it updates (Downloaded) every time and does not remember where it left off. Obviously the break is causing a problem here too.
I thought about making a table that updates each item that has previously been selected so then the search could check there and continue on to the next needed row. Unsure how to implement that too.
arcpy
Maybe you could provide a few lines of the attribute table that show what you have and what you want to happen? You have the table sorted by count, and then you want Yes to be written under Downloaded . . . . when? Or, rather, what would be the situation where you'd want Downloaded to remain No?
– J Kelly
Apr 3 at 0:10
There's an awful lot of "snippet" code for the task of getting the first row. Since DA Cursors return an array you could just return element zero. Or, faster, use the cursor.next() operator to return only the first row. Or add abreak
in the loop after the first iteration.
– Vince
Apr 3 at 0:37
I have actually rewritten everything of this in a much nicer script which is working a million times better. I will delete the question but just wanted to say thank you for taking the time to look this over.
– Benjam
Apr 3 at 0:54
add a comment |
Currently I am trying to select the top row of a feature class which is sorted using a Count field. I then would like to run the script a second time but the result will then be the second row of the table. I currently have the script below.
#import arcpy module
import arcpy
from arcpy import env
env.workspace = "D:\Trimble.gdb"
#allow overwrites
arcpy.env.overwriteOutput = True
#print list of feature classes
featList = arcpy.ListFeatureClasses()
print featList
#cheack if Messages and Township spatial join has been made
for feat in featList:
if arcpy.Exists("TWP_Messages"):
print "Township and Messages Without Roads joined already"
print ""
break
else:
#create spatial join between Messages and Townships
target_features = "D:\Trimble.gdb\TWP"
join_features = "D:\Trimble.gdb\Messages"
out_feature = "D:\Trimble.gdb\TWP_Messages"
arcpy.SpatialJoin_analysis(target_features, join_features, out_feature)
#sort Join_Count field by Descending
arcpy.Sort_management("TWP_Messages", "TWP_Messages_Sort", [["Count_", "DESCENDING"]])
print arcpy.GetMessage(2)
messageSort = "D:\Trimble.gdb\TWP_Messages_Sort"
#add field to messages sort feature to describe if item has been deleted already
arcpy.AddField_management(messageSort, "Downloaded", "TEXT")
#update all Downloaded fields to No
with arcpy.da.UpdateCursor(messageSort, "Downloaded") as cursor:
for row in cursor:
row[0] = "No"
cursor.updateRow(row)
del row
del cursor
messageSorted = "D:\Trimble.gdb\TWP_Messages_Sort"
i = 0
with arcpy.da.SearchCursor(messageSorted, ["DESCRIPTOR", "Count_"]) as cursor:
for row in cursor:
if row[1] != i:
print("Descriptor: Count: ".format(row[0], row[1]))
i = row[1]
name = row[0]
with arcpy.da.UpdateCursor(messageSorted, ["Count_", "Downloaded"]) as curs:
for line in curs:
if line[0] == i:
line[1] = "Yes"
curs.updateRow(line)
break
print name
Currently it is rewriting the fields it updates (Downloaded) every time and does not remember where it left off. Obviously the break is causing a problem here too.
I thought about making a table that updates each item that has previously been selected so then the search could check there and continue on to the next needed row. Unsure how to implement that too.
arcpy
Currently I am trying to select the top row of a feature class which is sorted using a Count field. I then would like to run the script a second time but the result will then be the second row of the table. I currently have the script below.
#import arcpy module
import arcpy
from arcpy import env
env.workspace = "D:\Trimble.gdb"
#allow overwrites
arcpy.env.overwriteOutput = True
#print list of feature classes
featList = arcpy.ListFeatureClasses()
print featList
#cheack if Messages and Township spatial join has been made
for feat in featList:
if arcpy.Exists("TWP_Messages"):
print "Township and Messages Without Roads joined already"
print ""
break
else:
#create spatial join between Messages and Townships
target_features = "D:\Trimble.gdb\TWP"
join_features = "D:\Trimble.gdb\Messages"
out_feature = "D:\Trimble.gdb\TWP_Messages"
arcpy.SpatialJoin_analysis(target_features, join_features, out_feature)
#sort Join_Count field by Descending
arcpy.Sort_management("TWP_Messages", "TWP_Messages_Sort", [["Count_", "DESCENDING"]])
print arcpy.GetMessage(2)
messageSort = "D:\Trimble.gdb\TWP_Messages_Sort"
#add field to messages sort feature to describe if item has been deleted already
arcpy.AddField_management(messageSort, "Downloaded", "TEXT")
#update all Downloaded fields to No
with arcpy.da.UpdateCursor(messageSort, "Downloaded") as cursor:
for row in cursor:
row[0] = "No"
cursor.updateRow(row)
del row
del cursor
messageSorted = "D:\Trimble.gdb\TWP_Messages_Sort"
i = 0
with arcpy.da.SearchCursor(messageSorted, ["DESCRIPTOR", "Count_"]) as cursor:
for row in cursor:
if row[1] != i:
print("Descriptor: Count: ".format(row[0], row[1]))
i = row[1]
name = row[0]
with arcpy.da.UpdateCursor(messageSorted, ["Count_", "Downloaded"]) as curs:
for line in curs:
if line[0] == i:
line[1] = "Yes"
curs.updateRow(line)
break
print name
Currently it is rewriting the fields it updates (Downloaded) every time and does not remember where it left off. Obviously the break is causing a problem here too.
I thought about making a table that updates each item that has previously been selected so then the search could check there and continue on to the next needed row. Unsure how to implement that too.
arcpy
arcpy
edited Apr 3 at 0:31
Vince
14.8k32849
14.8k32849
asked Apr 2 at 23:47
BenjamBenjam
156
156
Maybe you could provide a few lines of the attribute table that show what you have and what you want to happen? You have the table sorted by count, and then you want Yes to be written under Downloaded . . . . when? Or, rather, what would be the situation where you'd want Downloaded to remain No?
– J Kelly
Apr 3 at 0:10
There's an awful lot of "snippet" code for the task of getting the first row. Since DA Cursors return an array you could just return element zero. Or, faster, use the cursor.next() operator to return only the first row. Or add abreak
in the loop after the first iteration.
– Vince
Apr 3 at 0:37
I have actually rewritten everything of this in a much nicer script which is working a million times better. I will delete the question but just wanted to say thank you for taking the time to look this over.
– Benjam
Apr 3 at 0:54
add a comment |
Maybe you could provide a few lines of the attribute table that show what you have and what you want to happen? You have the table sorted by count, and then you want Yes to be written under Downloaded . . . . when? Or, rather, what would be the situation where you'd want Downloaded to remain No?
– J Kelly
Apr 3 at 0:10
There's an awful lot of "snippet" code for the task of getting the first row. Since DA Cursors return an array you could just return element zero. Or, faster, use the cursor.next() operator to return only the first row. Or add abreak
in the loop after the first iteration.
– Vince
Apr 3 at 0:37
I have actually rewritten everything of this in a much nicer script which is working a million times better. I will delete the question but just wanted to say thank you for taking the time to look this over.
– Benjam
Apr 3 at 0:54
Maybe you could provide a few lines of the attribute table that show what you have and what you want to happen? You have the table sorted by count, and then you want Yes to be written under Downloaded . . . . when? Or, rather, what would be the situation where you'd want Downloaded to remain No?
– J Kelly
Apr 3 at 0:10
Maybe you could provide a few lines of the attribute table that show what you have and what you want to happen? You have the table sorted by count, and then you want Yes to be written under Downloaded . . . . when? Or, rather, what would be the situation where you'd want Downloaded to remain No?
– J Kelly
Apr 3 at 0:10
There's an awful lot of "snippet" code for the task of getting the first row. Since DA Cursors return an array you could just return element zero. Or, faster, use the cursor.next() operator to return only the first row. Or add a
break
in the loop after the first iteration.– Vince
Apr 3 at 0:37
There's an awful lot of "snippet" code for the task of getting the first row. Since DA Cursors return an array you could just return element zero. Or, faster, use the cursor.next() operator to return only the first row. Or add a
break
in the loop after the first iteration.– Vince
Apr 3 at 0:37
I have actually rewritten everything of this in a much nicer script which is working a million times better. I will delete the question but just wanted to say thank you for taking the time to look this over.
– Benjam
Apr 3 at 0:54
I have actually rewritten everything of this in a much nicer script which is working a million times better. I will delete the question but just wanted to say thank you for taking the time to look this over.
– Benjam
Apr 3 at 0:54
add a comment |
1 Answer
1
active
oldest
votes
Since posting this I have rethought the process and have come up with this code which is working exactly how I wanted. Just had to get past the old brain muddling.
#import arcpy module
import arcpy
arcpy.env.workspace = "D:\Trimble.gdb"
#create variable of the sorted message and township feature class
messageSorted = "D:\Trimble.gdb\TWP_Messages_Sort"
#select the first row of the feature that has not been downloaded previously
i = 0
with arcpy.da.SearchCursor(messageSorted, ["TRM", "Downloaded"]) as cursor:
for row in cursor:
if i == 1:
break
else:
if row[1] == "Yes":
continue
else:
TWP = row[0]
i += 1
print TWP
del row
del cursor
#update the new selected line to downloaded so it is not selected again
with arcpy.da.UpdateCursor(messageSorted, ["TRM", "Downloaded"]) as cursor:
for row in cursor:
if row[0] == TWP:
row[1] = "Yes"
cursor.updateRow(row)
del row
del cursor
1
That's still gobs more complicated than putting a non-conditional break after the innerif
and removing the outerif
. You also don't need to delete the cursor (with
handles that)
– Vince
Apr 3 at 1:22
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317568%2fselecting-just-the-first-row-from-a-search-cursor%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Since posting this I have rethought the process and have come up with this code which is working exactly how I wanted. Just had to get past the old brain muddling.
#import arcpy module
import arcpy
arcpy.env.workspace = "D:\Trimble.gdb"
#create variable of the sorted message and township feature class
messageSorted = "D:\Trimble.gdb\TWP_Messages_Sort"
#select the first row of the feature that has not been downloaded previously
i = 0
with arcpy.da.SearchCursor(messageSorted, ["TRM", "Downloaded"]) as cursor:
for row in cursor:
if i == 1:
break
else:
if row[1] == "Yes":
continue
else:
TWP = row[0]
i += 1
print TWP
del row
del cursor
#update the new selected line to downloaded so it is not selected again
with arcpy.da.UpdateCursor(messageSorted, ["TRM", "Downloaded"]) as cursor:
for row in cursor:
if row[0] == TWP:
row[1] = "Yes"
cursor.updateRow(row)
del row
del cursor
1
That's still gobs more complicated than putting a non-conditional break after the innerif
and removing the outerif
. You also don't need to delete the cursor (with
handles that)
– Vince
Apr 3 at 1:22
add a comment |
Since posting this I have rethought the process and have come up with this code which is working exactly how I wanted. Just had to get past the old brain muddling.
#import arcpy module
import arcpy
arcpy.env.workspace = "D:\Trimble.gdb"
#create variable of the sorted message and township feature class
messageSorted = "D:\Trimble.gdb\TWP_Messages_Sort"
#select the first row of the feature that has not been downloaded previously
i = 0
with arcpy.da.SearchCursor(messageSorted, ["TRM", "Downloaded"]) as cursor:
for row in cursor:
if i == 1:
break
else:
if row[1] == "Yes":
continue
else:
TWP = row[0]
i += 1
print TWP
del row
del cursor
#update the new selected line to downloaded so it is not selected again
with arcpy.da.UpdateCursor(messageSorted, ["TRM", "Downloaded"]) as cursor:
for row in cursor:
if row[0] == TWP:
row[1] = "Yes"
cursor.updateRow(row)
del row
del cursor
1
That's still gobs more complicated than putting a non-conditional break after the innerif
and removing the outerif
. You also don't need to delete the cursor (with
handles that)
– Vince
Apr 3 at 1:22
add a comment |
Since posting this I have rethought the process and have come up with this code which is working exactly how I wanted. Just had to get past the old brain muddling.
#import arcpy module
import arcpy
arcpy.env.workspace = "D:\Trimble.gdb"
#create variable of the sorted message and township feature class
messageSorted = "D:\Trimble.gdb\TWP_Messages_Sort"
#select the first row of the feature that has not been downloaded previously
i = 0
with arcpy.da.SearchCursor(messageSorted, ["TRM", "Downloaded"]) as cursor:
for row in cursor:
if i == 1:
break
else:
if row[1] == "Yes":
continue
else:
TWP = row[0]
i += 1
print TWP
del row
del cursor
#update the new selected line to downloaded so it is not selected again
with arcpy.da.UpdateCursor(messageSorted, ["TRM", "Downloaded"]) as cursor:
for row in cursor:
if row[0] == TWP:
row[1] = "Yes"
cursor.updateRow(row)
del row
del cursor
Since posting this I have rethought the process and have come up with this code which is working exactly how I wanted. Just had to get past the old brain muddling.
#import arcpy module
import arcpy
arcpy.env.workspace = "D:\Trimble.gdb"
#create variable of the sorted message and township feature class
messageSorted = "D:\Trimble.gdb\TWP_Messages_Sort"
#select the first row of the feature that has not been downloaded previously
i = 0
with arcpy.da.SearchCursor(messageSorted, ["TRM", "Downloaded"]) as cursor:
for row in cursor:
if i == 1:
break
else:
if row[1] == "Yes":
continue
else:
TWP = row[0]
i += 1
print TWP
del row
del cursor
#update the new selected line to downloaded so it is not selected again
with arcpy.da.UpdateCursor(messageSorted, ["TRM", "Downloaded"]) as cursor:
for row in cursor:
if row[0] == TWP:
row[1] = "Yes"
cursor.updateRow(row)
del row
del cursor
answered Apr 3 at 0:56
BenjamBenjam
156
156
1
That's still gobs more complicated than putting a non-conditional break after the innerif
and removing the outerif
. You also don't need to delete the cursor (with
handles that)
– Vince
Apr 3 at 1:22
add a comment |
1
That's still gobs more complicated than putting a non-conditional break after the innerif
and removing the outerif
. You also don't need to delete the cursor (with
handles that)
– Vince
Apr 3 at 1:22
1
1
That's still gobs more complicated than putting a non-conditional break after the inner
if
and removing the outer if
. You also don't need to delete the cursor (with
handles that)– Vince
Apr 3 at 1:22
That's still gobs more complicated than putting a non-conditional break after the inner
if
and removing the outer if
. You also don't need to delete the cursor (with
handles that)– Vince
Apr 3 at 1:22
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317568%2fselecting-just-the-first-row-from-a-search-cursor%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Maybe you could provide a few lines of the attribute table that show what you have and what you want to happen? You have the table sorted by count, and then you want Yes to be written under Downloaded . . . . when? Or, rather, what would be the situation where you'd want Downloaded to remain No?
– J Kelly
Apr 3 at 0:10
There's an awful lot of "snippet" code for the task of getting the first row. Since DA Cursors return an array you could just return element zero. Or, faster, use the cursor.next() operator to return only the first row. Or add a
break
in the loop after the first iteration.– Vince
Apr 3 at 0:37
I have actually rewritten everything of this in a much nicer script which is working a million times better. I will delete the question but just wanted to say thank you for taking the time to look this over.
– Benjam
Apr 3 at 0:54