<?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: update cursor using a wildcard in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332165#M25858</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks everyone.&amp;nbsp; I tried everything on here and the first thing that worked was startswith() so thanks everyone it works perfectly now! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Mar 2016 00:04:18 GMT</pubDate>
    <dc:creator>jameljoseph</dc:creator>
    <dc:date>2016-03-18T00:04:18Z</dc:date>
    <item>
      <title>update cursor using a wildcard</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332157#M25850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using an update cursor in my python script to go through my table records and I want to assign the same value to all the universities that start with "University of".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example of what I want to do:&lt;/P&gt;&lt;P&gt;if row[0] == "Boston College":&lt;/P&gt;&lt;P&gt;[code here]&lt;/P&gt;&lt;P&gt;elif row[0] == "University of *":&lt;/P&gt;&lt;P&gt;[code here]&lt;/P&gt;&lt;P&gt;else:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought the * was the wildcard but all my records that have "University of" as the prefix in a record do not have any values in them, whereas Boston College does.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Mar 2016 19:32:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332157#M25850</guid>
      <dc:creator>jameljoseph</dc:creator>
      <dc:date>2016-03-17T19:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: update cursor using a wildcard</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332158#M25851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The star operator only works for the UpdateCursor fields parameter. I think in this case you can use the `in` operator:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;elif 'University of' in row[0]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #do stuff&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Mar 2016 19:41:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332158#M25851</guid>
      <dc:creator>roemhildtg</dc:creator>
      <dc:date>2016-03-17T19:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: update cursor using a wildcard</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332159#M25852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;there are a variety of ways, here is one&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = "university of"
&amp;gt;&amp;gt;&amp;gt; b = "university of pythonia"
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; a in b
True
&amp;gt;&amp;gt;&amp;gt; "college" in b
False&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:43:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332159#M25852</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T15:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: update cursor using a wildcard</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332160#M25853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For your purposes, 'in' should work, however it doesn't guarantee that the string starts with those characters. I'll just point out that there is '&lt;A href="https://docs.python.org/2/library/stdtypes.html#str.startswith" rel="nofollow noopener noreferrer" target="_blank"&gt;startswith()&lt;/A&gt;' that tests string beginnings:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = "university of"&amp;nbsp; 
... b = "university of pythonia"
... c = "pythonia university of"
... print b.startswith(a) # does b start with a?
... print c.startswith(a) # does c start with a?
... 
True
False&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or, an alternative using slice notation:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = "university of"&amp;nbsp; 
... b = "university of pythonia"
... c = "pythonia university of"
... print b[:len(a)] == a # do the first few items (letters) in b equal a?
... print c[:len(a)] == a # do the first few items (letters) in c equal a?
... 
True
False&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:43:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332160#M25853</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T15:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: update cursor using a wildcard</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332161#M25854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;then you could have the best of both worlds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a = "university of pythonia"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; "pythonia" in a.split(" ")&lt;/P&gt;&lt;P&gt;True&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Mar 2016 20:21:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332161#M25854</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-17T20:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: update cursor using a wildcard</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332162#M25855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'll play along. If you're determined to use split to test a string beginning...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = "university of" 
... b = "university of pythonia"
... c = "pythonia university of"
... print b.split(a)[0] == '' # if b is split by a, is the first item in the returned list blank?
... print c.split(a)[0] == '' # if c is split by a, is the first item in the returned list blank?
...
True
False&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:43:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332162#M25855</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T15:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: update cursor using a wildcard</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332163#M25856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/laugh.png" /&gt;&amp;nbsp; I will work on some numpy examples then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Update&lt;/P&gt;&lt;P&gt;2D question demonstrated...extendable to N dimensions&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; arr
array([['university'],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ['of'],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ['pythonia']], 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dtype='|S10')
&amp;gt;&amp;gt;&amp;gt; np.any(np.where(arr=="pythonia",True,False))
True&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:43:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332163#M25856</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T15:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: update cursor using a wildcard</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332164#M25857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I second &lt;A href="https://community.esri.com/migrated-users/19932" target="_blank"&gt;Darren Wiens&lt;/A&gt; in using &lt;SPAN style="font-family: 'courier new', courier;"&gt;startswith()&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if row[0] == "Boston College":
&amp;nbsp;&amp;nbsp;&amp;nbsp; # [code here]
elif row[0].startswith("University of "):
&amp;nbsp;&amp;nbsp;&amp;nbsp; # [code here]
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # [code here]&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just make sure the field you're doing this on has only strings (text). The code above will error if it hits a number or date value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:44:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332164#M25857</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T15:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: update cursor using a wildcard</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332165#M25858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks everyone.&amp;nbsp; I tried everything on here and the first thing that worked was startswith() so thanks everyone it works perfectly now! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Mar 2016 00:04:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-using-a-wildcard/m-p/332165#M25858</guid>
      <dc:creator>jameljoseph</dc:creator>
      <dc:date>2016-03-18T00:04:18Z</dc:date>
    </item>
  </channel>
</rss>

