<?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 (if namefield LIKE '% value%') in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-if-namefield-like-value/m-p/564168#M44143</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/225159"&gt;Carlos Bustamante&lt;/A&gt;‌, still having issues?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Dec 2019 23:53:58 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2019-12-13T23:53:58Z</dc:date>
    <item>
      <title>using (if namefield LIKE '% value%')</title>
      <link>https://community.esri.com/t5/python-questions/using-if-namefield-like-value/m-p/564166#M44141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am calculating a field with arcpy, but I have not been able to obtain the expected results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
expression2=&lt;SPAN style="color: #a5c261;"&gt;"getClass(!DESCRIPCION!)"
&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;
&lt;/SPAN&gt;codeblock2=&lt;SPAN style="color: #a5c261;"&gt;"""def &lt;/SPAN&gt;&lt;SPAN style="color: #ffc66d;"&gt;getClass&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;DESCRIPCION&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;):
&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;    if '"DESCRIPCION" LIKE ' + "'%CODE%":
&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;        return 1 """
&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;
&lt;/SPAN&gt;arcpy.CalculateField_management(&lt;SPAN style="color: #aa4926;"&gt;in_table&lt;/SPAN&gt;=out_gdb +   &lt;SPAN style="color: #a5c261;"&gt;"\Compilado\AccesoriosLineasMecanicas"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;                                &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;field&lt;/SPAN&gt;=&lt;SPAN style="color: #a5c261;"&gt;"TIPO_EMPALME"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;                                &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;expression&lt;/SPAN&gt;=expression2&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;                                &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;expression_type&lt;/SPAN&gt;=&lt;SPAN style="color: #a5c261;"&gt;"PYTHON_9.3"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;                                &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;code_block&lt;/SPAN&gt;=codeblock2)&lt;/PRE&gt;&lt;P&gt;for all records in the TIPO_EMPALME field the result is 1,&amp;nbsp;I should do a filter for %CODE%&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:18:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-if-namefield-like-value/m-p/564166#M44141</guid>
      <dc:creator>CarlosBustamante</dc:creator>
      <dc:date>2021-12-12T00:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: using (if namefield LIKE '% value%')</title>
      <link>https://community.esri.com/t5/python-questions/using-if-namefield-like-value/m-p/564167#M44142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are setting the code block to Python but using SQL syntax, so it isn't a surprise the code isn't working.&amp;nbsp; Try using Python syntax, something along the lines of:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'CODE'&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; DESCRIPCION&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:18:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-if-namefield-like-value/m-p/564167#M44142</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-12T00:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: using (if namefield LIKE '% value%')</title>
      <link>https://community.esri.com/t5/python-questions/using-if-namefield-like-value/m-p/564168#M44143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/225159"&gt;Carlos Bustamante&lt;/A&gt;‌, still having issues?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Dec 2019 23:53:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-if-namefield-like-value/m-p/564168#M44143</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-12-13T23:53:58Z</dc:date>
    </item>
  </channel>
</rss>

