<?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 a search Cursor I keep getting an error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-a-search-cursor-i-keep-getting-an-error/m-p/141876#M11042</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What's the error message?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As it is now, it looks like the line Poyl_name = row[0] is commented out (although I don't see the '#'), so there is no variable called Poyl_name. If it's not commented out, then it's trying to use row[0], while you've already called it x[0].&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Feb 2017 02:10:25 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2017-02-03T02:10:25Z</dc:date>
    <item>
      <title>Using a search Cursor I keep getting an error</title>
      <link>https://community.esri.com/t5/python-questions/using-a-search-cursor-i-keep-getting-an-error/m-p/141875#M11041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I am using a search cursor to run through each row and multi buffer&amp;nbsp; - having a few dramas and I cant seem to get my head around it!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume its to do with how I am calling row into the buffer ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;import &lt;/SPAN&gt;arcpy
&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;from &lt;/SPAN&gt;arcpy &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;import &lt;/SPAN&gt;env
arcpy.env.overwriteOutput = &lt;SPAN style="color: #8888c6;"&gt;True
&lt;/SPAN&gt;&lt;SPAN style="color: #8888c6;"&gt;
&lt;/SPAN&gt;file_workspace = &lt;SPAN style="color: #a5c261;"&gt;"r'N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Search_Cursor.gdb"
&lt;/SPAN&gt;env.workspace = file_workspace

Holdings = &lt;SPAN style="color: #a5c261;"&gt;r'N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Search_Cursor.gdb\Data\Holdings'
&lt;/SPAN&gt;ofc = &lt;SPAN style="color: #a5c261;"&gt;r'N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Search_Cursor.gdb'
&lt;/SPAN&gt;distances = [&lt;SPAN style="color: #6897bb;"&gt;1000&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6897bb;"&gt;4000&lt;/SPAN&gt;]
unit = &lt;SPAN style="color: #a5c261;"&gt;"Meters"
&lt;/SPAN&gt;arcpy.MakeFeatureLayer_management(Holdings&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'Holdings_Layer'&lt;/SPAN&gt;)

&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;with &lt;/SPAN&gt;arcpy.da.SearchCursor(Holdings&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;[&lt;SPAN style="color: #a5c261;"&gt;'Holding_Reference_Number'&lt;/SPAN&gt;])&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;as &lt;/SPAN&gt;Holdings_Ref_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;for &lt;/SPAN&gt;x &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;in &lt;/SPAN&gt;Holdings_Ref_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;print &lt;/SPAN&gt;x[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #808080;"&gt;Poyl_name = row[0]
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;arcpy.SelectLayerByAttribute_management(&lt;SPAN style="color: #a5c261;"&gt;'Holdings_Layer'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'NEW_SELECTION'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'"' &lt;/SPAN&gt;+ Holdings + &lt;SPAN style="color: #a5c261;"&gt;'" = \'' &lt;/SPAN&gt;+ Poyl_name + &lt;SPAN style="color: #a5c261;"&gt;'\''&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MultipleRingBuffer_analysis(&lt;SPAN style="color: #a5c261;"&gt;'Holdings_Layer'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'ofc'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;distances&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;unit&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"ALL"&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #808080;"&gt;#arcpy.Buffer_analysis("Holdings_Layer", ofc, var_Buffer, "FULL", "ROUND", "ALL", "")
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;print &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'Buffer complete'
&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #a5c261;"&gt;'Buffer Complete'&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="color: #263238; font-family: Roboto, Arial, sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:48:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-search-cursor-i-keep-getting-an-error/m-p/141875#M11041</guid>
      <dc:creator>Leith_JohnHAWKINS</dc:creator>
      <dc:date>2021-12-11T07:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using a search Cursor I keep getting an error</title>
      <link>https://community.esri.com/t5/python-questions/using-a-search-cursor-i-keep-getting-an-error/m-p/141876#M11042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What's the error message?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As it is now, it looks like the line Poyl_name = row[0] is commented out (although I don't see the '#'), so there is no variable called Poyl_name. If it's not commented out, then it's trying to use row[0], while you've already called it x[0].&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2017 02:10:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-search-cursor-i-keep-getting-an-error/m-p/141876#M11042</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2017-02-03T02:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using a search Cursor I keep getting an error</title>
      <link>https://community.esri.com/t5/python-questions/using-a-search-cursor-i-keep-getting-an-error/m-p/141877#M11043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry I forgot to add the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I have made some changes but still getting that the row is not defined ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;import &lt;/SPAN&gt;arcpy
&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;from &lt;/SPAN&gt;arcpy &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;import &lt;/SPAN&gt;env
arcpy.env.overwriteOutput = &lt;SPAN style="color: #8888c6;"&gt;True
&lt;/SPAN&gt;&lt;SPAN style="color: #8888c6;"&gt;
&lt;/SPAN&gt;file_workspace = &lt;SPAN style="color: #a5c261;"&gt;"r'N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Search_Cursor.gdb"
&lt;/SPAN&gt;env.workspace = file_workspace

Holdings = &lt;SPAN style="color: #a5c261;"&gt;r'N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Search_Cursor.gdb\Data\Holdings'
&lt;/SPAN&gt;ofc = &lt;SPAN style="color: #a5c261;"&gt;r'N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Search_Cursor.gdb'
&lt;/SPAN&gt;distances = [&lt;SPAN style="color: #6897bb;"&gt;1000&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6897bb;"&gt;4000&lt;/SPAN&gt;]
unit = &lt;SPAN style="color: #a5c261;"&gt;"Meters"
&lt;/SPAN&gt;arcpy.MakeFeatureLayer_management(Holdings&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'Holdings_Layer'&lt;/SPAN&gt;)

&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;with &lt;/SPAN&gt;arcpy.da.SearchCursor(Holdings&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;[&lt;SPAN style="color: #a5c261;"&gt;'Holding_Reference_Number'&lt;/SPAN&gt;])&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;as &lt;/SPAN&gt;Holdings_Ref_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;for &lt;/SPAN&gt;x &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;in &lt;/SPAN&gt;Holdings_Ref_cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;print &lt;/SPAN&gt;x[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;] = row[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(&lt;SPAN style="color: #a5c261;"&gt;'Holdings_Layer'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'NEW_SELECTION'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'"' &lt;/SPAN&gt;+ Holdings + &lt;SPAN style="color: #a5c261;"&gt;'" = \' + x[0]' &lt;/SPAN&gt;+ &lt;SPAN style="color: #a5c261;"&gt;'\''&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MultipleRingBuffer_analysis(&lt;SPAN style="color: #a5c261;"&gt;'Holdings_Layer'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'ofc'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;distances&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;unit&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"ALL"&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #808080;"&gt;#arcpy.Buffer_analysis("Holdings_Layer", ofc, var_Buffer, "FULL", "ROUND", "ALL", "")
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;print &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'Buffer complete'
&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #a5c261;"&gt;'Buffer Complete'&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:48:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-search-cursor-i-keep-getting-an-error/m-p/141877#M11043</guid>
      <dc:creator>Leith_JohnHAWKINS</dc:creator>
      <dc:date>2021-12-11T07:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using a search Cursor I keep getting an error</title>
      <link>https://community.esri.com/t5/python-questions/using-a-search-cursor-i-keep-getting-an-error/m-p/141878#M11044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's because you've called 'x' what most examples call 'row' (it would normally be more like "for row in cursor:"). It doesn't matter, it's just a variable name, but if you call it 'x', then you need to reference 'x' (i.e. x[0] is the Holding_Reference_Number). Or, you can't set x[0] to row[0], because row doesn't exist. Also, you've got a new error coming up in the select - there's an extra apostrophe right after x[0].&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2017 02:28:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-search-cursor-i-keep-getting-an-error/m-p/141878#M11044</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2017-02-03T02:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using a search Cursor I keep getting an error</title>
      <link>https://community.esri.com/t5/python-questions/using-a-search-cursor-i-keep-getting-an-error/m-p/141879#M11045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks makes sense ill implement&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2017 02:33:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-search-cursor-i-keep-getting-an-error/m-p/141879#M11045</guid>
      <dc:creator>Leith_JohnHAWKINS</dc:creator>
      <dc:date>2017-02-03T02:33:59Z</dc:date>
    </item>
  </channel>
</rss>

