<?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: ModelBuilder - Convert VB Script to Python Coding HELP!! in ModelBuilder Questions</title>
    <link>https://community.esri.com/t5/modelbuilder-questions/modelbuilder-convert-vb-script-to-python-coding/m-p/870216#M1038</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM style="background-color: #ffffff; "&gt;In short, the tool needs to find the number (typically "55" or "60" always a double number) in a column/field (let's call it "Address") and populate the "Number" field/column with the number.&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM style="background-color: #ffffff; "&gt;&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Is the Address field a double or text type?&amp;nbsp; I'm not exactly sure what it is you are trying to do; I'm sure it's not as simple as calculating one field based on the value of another field.&amp;nbsp; Or is it?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Jan 2020 21:03:52 GMT</pubDate>
    <dc:creator>JoeBorgione</dc:creator>
    <dc:date>2020-01-22T21:03:52Z</dc:date>
    <item>
      <title>ModelBuilder - Convert VB Script to Python Coding HELP!!</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/modelbuilder-convert-vb-script-to-python-coding/m-p/870215#M1037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone and thank you in advance for all your answers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First thing first - I am a beginner in Python and I might ask stupid questions. Hopefully this won't be one of them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have an old tool that works perfectly in ArcMap but recently we had no choice but convert it to PRO. I ran the analyse tool in geoprocessor to open the "old toolbox" in PRO and I can edit the model. After going through all the tools and testing I found that some of the "Calculate Field" tools are in VB. So these need to change it to Python for it to run in PRO.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In short, the tool needs to find the number (typically "55" or "60" always a double number) in a column/field (let's call it "Address") and populate the "Number" field/column with the number.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The current strict is as follw:&lt;/P&gt;&lt;P&gt;&amp;nbsp;Number =&amp;nbsp;&lt;BR /&gt;is_string(!MAX_%Field Name%!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code Block&lt;/P&gt;&lt;P&gt;def is_string(s):&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if isinstance(s, basestring) == True:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;num = ''&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;for i in s:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if i in '01234567890':&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;num+=i&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;integer = int(num)&lt;BR /&gt; return integer&lt;BR /&gt; if isinstance(s, basestring) == False:&lt;BR /&gt; return s&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help on this would be great thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jan 2020 20:37:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/modelbuilder-convert-vb-script-to-python-coding/m-p/870215#M1037</guid>
      <dc:creator>deleted-user-A8p9VIOt44Kb</dc:creator>
      <dc:date>2020-01-22T20:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: ModelBuilder - Convert VB Script to Python Coding HELP!!</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/modelbuilder-convert-vb-script-to-python-coding/m-p/870216#M1038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM style="background-color: #ffffff; "&gt;In short, the tool needs to find the number (typically "55" or "60" always a double number) in a column/field (let's call it "Address") and populate the "Number" field/column with the number.&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM style="background-color: #ffffff; "&gt;&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Is the Address field a double or text type?&amp;nbsp; I'm not exactly sure what it is you are trying to do; I'm sure it's not as simple as calculating one field based on the value of another field.&amp;nbsp; Or is it?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jan 2020 21:03:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/modelbuilder-convert-vb-script-to-python-coding/m-p/870216#M1038</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2020-01-22T21:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: ModelBuilder - Convert VB Script to Python Coding HELP!!</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/modelbuilder-convert-vb-script-to-python-coding/m-p/870217#M1039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The Address field is a Text type. Example&lt;/P&gt;&lt;P&gt;In the Address Field/column, a feature would have the following, "ABCD_55" I need the "55" to populate the other field/column Called "Number".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jan 2020 21:09:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/modelbuilder-convert-vb-script-to-python-coding/m-p/870217#M1039</guid>
      <dc:creator>deleted-user-A8p9VIOt44Kb</dc:creator>
      <dc:date>2020-01-22T21:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: ModelBuilder - Convert VB Script to Python Coding HELP!!</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/modelbuilder-convert-vb-script-to-python-coding/m-p/870218#M1040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If they always have an underscore separating the alpha characters from the numeric characters, you can use the split() function in the field calculator something like this:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;NumberFieldName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;!Address!&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'_'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&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;P&gt;&lt;/P&gt;&lt;P&gt;That just splits the the value of whatever is in the Address field at the underscore and turns the #1 element (it is 0 based) into an integer.&amp;nbsp; 'ABCD' is element[0]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jan 2020 21:35:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/modelbuilder-convert-vb-script-to-python-coding/m-p/870218#M1040</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2020-01-22T21:35:14Z</dc:date>
    </item>
  </channel>
</rss>

