<?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 Python to query a text string in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-python-to-query-a-text-string/m-p/218785#M16835</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Aaron,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;query_result1 = feature_layer.query(where="recordCulvertCorrect='no'", &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; out_fields='objectid,globalid,Date_,CulvertName,pullCulvertMaterial,pullCulvertDiameter')&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Mar 2018 19:05:23 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2018-03-02T19:05:23Z</dc:date>
    <item>
      <title>Using Python to query a text string</title>
      <link>https://community.esri.com/t5/python-questions/using-python-to-query-a-text-string/m-p/218784#M16834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm just getting started with Python and was following the example in:&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/python/guide/working-with-feature-layers-and-features/" title="https://developers.arcgis.com/python/guide/working-with-feature-layers-and-features/"&gt;Using Feature Layers | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was able to follow the example but then I tried to manipulate it to use my data.&amp;nbsp; Everything was good until I got to the query.&amp;nbsp; I was able to query the numerical data fine but when I tried to pull a text value I couldn't make it work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried a couple different ways but the one that seems to closest (to my admittedly untrained eye) is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;query_result1 = feature_layer.query(where='recordCulvertCorrect=' "no"', &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; out_fields='objectid,globalid,Date_,CulvertName,pullCulvertMaterial,pullCulvertDiameter')&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My guess is it has to do with the way I am trying to work with the text string but I can't see to find what I'm looking for on line.&amp;nbsp; Any help is appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2018 19:01:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-to-query-a-text-string/m-p/218784#M16834</guid>
      <dc:creator>AaronButterer</dc:creator>
      <dc:date>2018-03-02T19:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to query a text string</title>
      <link>https://community.esri.com/t5/python-questions/using-python-to-query-a-text-string/m-p/218785#M16835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Aaron,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;query_result1 = feature_layer.query(where="recordCulvertCorrect='no'", &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; out_fields='objectid,globalid,Date_,CulvertName,pullCulvertMaterial,pullCulvertDiameter')&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2018 19:05:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-to-query-a-text-string/m-p/218785#M16835</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2018-03-02T19:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to query a text string</title>
      <link>https://community.esri.com/t5/python-questions/using-python-to-query-a-text-string/m-p/218786#M16836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a quick guess.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;query_result1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; feature_layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;query&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;where&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"recordCulvertCorrect='no'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; out_fields&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'objectid,globalid,Date_,CulvertName,pullCulvertMaterial,pullCulvertDiameter'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2018 19:06:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-to-query-a-text-string/m-p/218786#M16836</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2018-03-02T19:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to query a text string</title>
      <link>https://community.esri.com/t5/python-questions/using-python-to-query-a-text-string/m-p/218787#M16837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That did it.&amp;nbsp; Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2018 19:09:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-to-query-a-text-string/m-p/218787#M16837</guid>
      <dc:creator>AaronButterer</dc:creator>
      <dc:date>2018-03-02T19:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to query a text string</title>
      <link>https://community.esri.com/t5/python-questions/using-python-to-query-a-text-string/m-p/218788#M16838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A bit after the fact but something I like to do is create a where/select statement to a variable.&amp;nbsp; This approach I use a lot because I'm always plowing through a list in a for loop:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;select &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'OBJECTID = {}'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;street_name_list&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"view"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"ADD_TO_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;select&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So the variable 'select' is the 'where clause' in&amp;nbsp; select layer by attribute method:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;SelectLayerByAttribute_management (in_layer_or_view, {selection_type}, {where_clause})&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:40:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-to-query-a-text-string/m-p/218788#M16838</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-11T10:40:49Z</dc:date>
    </item>
  </channel>
</rss>

