<?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 Using Variable for Where Clause in search cursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54234#M4277</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do I go about using a variable from a raw_input for the where clause in da.SearchCursor?&lt;/P&gt;&lt;P&gt;I can't seem to get the syntax correct&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;env.workspace=r"F:\GEOG_488\Final_Project_Data\FinalProject488.gdb"&lt;BR /&gt;fc="PARCELS" #Create variable for feature class&lt;BR /&gt;tc="ADDRESS_TEST_20"&amp;nbsp; #Create variable for table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HouseNumber = int(raw_input("Enter Address Number: ")) #User input House Number&lt;BR /&gt;print "Situs Addresses with "+ str(HouseNumber)+" for the Situs Number:"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;cursor = arcpy.da.SearchCursor(tc,["ADDR"],'"SA_House_Number"= HouseNumber') #Create search cursor where records = HouseNumber&lt;BR /&gt;for row in cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Situs Address with House Number"+str(HouseNumber)":",row[0]&lt;/P&gt;&lt;P&gt;del row, cursor&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Mar 2015 01:31:19 GMT</pubDate>
    <dc:creator>RyanTucker1</dc:creator>
    <dc:date>2015-03-31T01:31:19Z</dc:date>
    <item>
      <title>Using Variable for Where Clause in search cursor</title>
      <link>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54234#M4277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do I go about using a variable from a raw_input for the where clause in da.SearchCursor?&lt;/P&gt;&lt;P&gt;I can't seem to get the syntax correct&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;env.workspace=r"F:\GEOG_488\Final_Project_Data\FinalProject488.gdb"&lt;BR /&gt;fc="PARCELS" #Create variable for feature class&lt;BR /&gt;tc="ADDRESS_TEST_20"&amp;nbsp; #Create variable for table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HouseNumber = int(raw_input("Enter Address Number: ")) #User input House Number&lt;BR /&gt;print "Situs Addresses with "+ str(HouseNumber)+" for the Situs Number:"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;cursor = arcpy.da.SearchCursor(tc,["ADDR"],'"SA_House_Number"= HouseNumber') #Create search cursor where records = HouseNumber&lt;BR /&gt;for row in cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Situs Address with House Number"+str(HouseNumber)":",row[0]&lt;/P&gt;&lt;P&gt;del row, cursor&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Mar 2015 01:31:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54234#M4277</guid>
      <dc:creator>RyanTucker1</dc:creator>
      <dc:date>2015-03-31T01:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using Variable for Where Clause in search cursor</title>
      <link>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54235#M4278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Escape HouseNumber from the where clause string. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Mar 2015 04:20:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54235#M4278</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-03-31T04:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using Variable for Where Clause in search cursor</title>
      <link>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54236#M4279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="text-align: left;"&gt;&lt;SPAN lang="EN" style="color: #3d3d3d; font-family: 'Helvetica','sans-serif'; font-size: 10.5pt; mso-ansi-language: EN;"&gt;'"SA_House_Number" = ' + str(HouseNumber)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;SPAN lang="EN" style="color: #3d3d3d; font-family: 'Helvetica','sans-serif'; font-size: 10.5pt; mso-ansi-language: EN;"&gt;When the&lt;/SPAN&gt; &lt;SPAN lang="EN" style="color: #3d3d3d; font-family: 'Helvetica','sans-serif'; font-size: 10.5pt; mso-ansi-language: EN;"&gt;HouseNumber is inside the quotes it is not recognized as variable&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;SPAN lang="EN" style="color: #3d3d3d; font-family: 'Helvetica','sans-serif'; font-size: 10.5pt; mso-ansi-language: EN;"&gt;I am not sure you have to put the attribute name (SA_House_Number&lt;/SPAN&gt;) in quotes in the new versions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Mar 2015 04:57:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54236#M4279</guid>
      <dc:creator>ModyBuchbinder</dc:creator>
      <dc:date>2015-03-31T04:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using Variable for Where Clause in search cursor</title>
      <link>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54237#M4280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I encourage you to learn about Python string formatting (&lt;A href="https://docs.python.org/2/library/string.html#format-string-syntax"&gt;Format String Syntax&lt;/A&gt;).&amp;nbsp; It is extremely robust.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14278078529621713" data-renderedposition="50_8_912_16" jivemacro_uid="_14278078529621713"&gt;&lt;P&gt;cursor = arcpy.da.SearchCursor(tc,["ADDR"],"SA_House_Number = {}".format(HouseNumber))&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Mar 2015 13:17:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54237#M4280</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-03-31T13:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using Variable for Where Clause in search cursor</title>
      <link>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54238#M4281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for your help. It now works using both the suggestion from Mody and Joshua.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm now reading up on string formatting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ryan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Mar 2015 15:06:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54238#M4281</guid>
      <dc:creator>RyanTucker1</dc:creator>
      <dc:date>2015-03-31T15:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using Variable for Where Clause in search cursor</title>
      <link>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54239#M4282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua Bixby deserves a beer or milk shake if a teetotaler.&lt;/P&gt;&lt;P&gt;+1 for string formatting. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 21:11:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-variable-for-where-clause-in-search-cursor/m-p/54239#M4282</guid>
      <dc:creator>danashney</dc:creator>
      <dc:date>2015-06-15T21:11:33Z</dc:date>
    </item>
  </channel>
</rss>

