0

I'm stuck on results that arcpy.SearchCursor is outputting. I'm accessing a table on a database connection. When I run this, it crashes with an error: argument of type 'Row' is not iterable

I ended up changing the code below, to simply print the row, and it comes back with:

<geoprocessing row object object at 0x048F8440>

Any idea what I'm doing wrong or what I'm missing?

import arcpy import csv MyData = arcpy.SearchCursor("c:/users/Rando/AppData/Roaming/ESRI/Desktop10.7/ArcCatalog/DB.sde/RandoTable") Phrase = "Some Words" for row in MyData: if Phrase in row: TheAnswer = row.getValue("TheHeader") 
3
  • 2
    Don't use the deprecated arcpy.SearchCursor for new code. Instead use arcpy.da.SearchCursor, which returns a list of lists, and could potentially honor the in operator. (You'd still be better off using the where_clause parameter to implement the if.) Commented Mar 20, 2023 at 20:41
  • 1
    What field are you trying to search for "Some Words" in exactly? You can't just search a row for a phrase, you have to search the values of fields in a row for a phrase. Commented Mar 20, 2023 at 20:54
  • ThePhrase is generated from a previous search cursor. I've got to jump through 6 files, all tying a code together. For Example, in this last run, ThePhrase = "24A49032-0882-6D12-C0CD-0A810AA0087B" I'm trying to match that up to the 'SIGNAL' field of that table Made it a little further with the .da At least I failed in a different way. (It didn't find a match.) I'm probably doing it wrong. Commented Mar 20, 2023 at 21:00

1 Answer 1

0

@Vince .da for the win

import arcpy import csv ### My Column Headers fields = ['SearchingField1', 'SearchingField2', 'SIGNAL'] myData = arcpy.da.SearchCursor("c:/users/Rando/AppData/Roaming/ESRI/Desktop10.7/ArcCatalog/DB.sde/RandoTable", fields) phrase = "Some Words" for row in myData: if phrase in row: theAnswer = row[2] 
1
  • 2
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. Commented Mar 20, 2023 at 21:42

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.