<?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: Searching field with upper or lower case in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122693#M9536</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;does the UPPER() only for the first word or for more then one word?&lt;/P&gt;&lt;P&gt;The feature class attributes are like the following Desert Hills Road,Desert Wolf Lane etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Nov 2015 17:38:35 GMT</pubDate>
    <dc:creator>CCWeedcontrol</dc:creator>
    <dc:date>2015-11-05T17:38:35Z</dc:date>
    <item>
      <title>Searching field with upper or lower case</title>
      <link>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122689#M9532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a script that works good but only if the first letter of the input has the first letter upper case. &lt;/P&gt;&lt;P&gt;Currently every road name starts with an upper case letter. How can I format the expression to allow for either upper or lower case inputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy&amp;nbsp; 
arcpy.AddMessage("Starting")&amp;nbsp; 
pu = arcpy.GetParameterAsText(0)&amp;nbsp; 
arcpy.AddMessage(pu)&amp;nbsp; 
mxd = arcpy.mapping.MapDocument("CURRENT")&amp;nbsp; 
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&amp;nbsp; 
lyr = arcpy.mapping.ListLayers(mxd, "Roads", df)[0]

pu = arcpy.GetParameterAsText(0) 
arcpy.AddMessage(lyr.name)&amp;nbsp; 
expression = "FENAME LIKE '%{}%'".format(pu) 
arcpy.AddMessage(expression)&amp;nbsp; 
arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",expression)&amp;nbsp; 
df.extent = lyr.getSelectedExtent()&amp;nbsp; 

arcpy.RefreshActiveView()&amp;nbsp; 
arcpy.AddMessage("Completed")&amp;nbsp; 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:03:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122689#M9532</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2021-12-11T07:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Searching field with upper or lower case</title>
      <link>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122690#M9533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;Force both sides to uppercase, then compare (untested):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14467437965249576 jive_text_macro" data-renderedposition="47_8_912_16" jivemacro_uid="_14467437965249576"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;expression = &lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;"UCASE(FENAME) LIKE '%{}%'"&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;.format(pu.upper()) &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If pu = 'elm street', it would be turned to 'ELM STREET'. It would then match capitalized versions of records like 'Elm Street', 'ELM Street', 'eLm StReEt', etc., all of which would be treated like 'ELM STREET'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2015 17:18:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122690#M9533</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-11-05T17:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Searching field with upper or lower case</title>
      <link>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122691#M9534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for the reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;getting error on expression = "UCASE(FENAME)LIKE '%{}%'".format(pu.upper()) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:\GIS\Python Scripts\ZoomTo\ZoomToRoad.py", line 13, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",expression)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 6688, in SelectLayerByAttribute&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 000358: Invalid expression&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2015 17:26:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122691#M9534</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2015-11-05T17:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Searching field with upper or lower case</title>
      <link>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122692#M9535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like ArcGIS SQL uses UPPER() rather than UCASE().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_144674461142378 jive_text_macro" data-renderedposition="92_8_912_16" jivemacro_uid="_144674461142378"&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;UPPER(FENAME) LIKE '%{}%'".format(pu.upper())&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2015 17:31:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122692#M9535</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-11-05T17:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: Searching field with upper or lower case</title>
      <link>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122693#M9536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;does the UPPER() only for the first word or for more then one word?&lt;/P&gt;&lt;P&gt;The feature class attributes are like the following Desert Hills Road,Desert Wolf Lane etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2015 17:38:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122693#M9536</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2015-11-05T17:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Searching field with upper or lower case</title>
      <link>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122694#M9537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like it does. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2015 17:43:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122694#M9537</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2015-11-05T17:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Searching field with upper or lower case</title>
      <link>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122695#M9538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;UPPER() applies to the entire string within the parentheses: e.g. UPPER('Desert Hills') = 'DESERT HILLS'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2015 17:44:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-field-with-upper-or-lower-case/m-p/122695#M9538</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-11-05T17:44:28Z</dc:date>
    </item>
  </channel>
</rss>

