<?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: python field calculator issue in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349495#M1154</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The code you are showing does not show indentation of the action parts of the if statements. Python is very picky about white space and there must be indentation. I'm certain when you typed it into IDLE it supplied the indentation for you automatically.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if len(PageNum) == 1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PlatLink = r"\\Covsdesrv\GIS Common\Plats\00%s000%s.TIF"%(MapNum,MapNum,PageNum )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elif len(PageNum) == 2:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PlatLink = r"\\Covsdesrv\GIS Common\Plats\00%s00%s.TIF"%(MapNum,MapNum,PageNum)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elif len(PageNum) == 3:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PlatLink = r"\\Covsdesrv\GIS Common\Plats\00%s0%s.TIF"%(MapNum,MapNum,PageNum)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Jan 2011 22:11:39 GMT</pubDate>
    <dc:creator>PatrickOMalley</dc:creator>
    <dc:date>2011-01-28T22:11:39Z</dc:date>
    <item>
      <title>python field calculator issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349491#M1150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: frankv3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i am having trouble calculating a string field named Plat_Link in a polygon feature class that has an integer field named MAP_BOOK and an integer field name PAGE&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i tested this code in IDLE and it worked fine if MAP_BOOK and PAGE were set (see picture), but it will not work in the field calculator, an error of 000989 is returned&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the code was tried both of these ways (first way in attached picture):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MapNum = str(!MAP_BOOK!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PageNum = str(!PAGE!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if len(PageNum) == 1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; PlatLink = "\\\\" + "Covsdesrv" + '\\' + "GIS Common" + '\\' + "Plats" + '\\' + "00" + MapNum + '\\' + "00" + MapNum + "000" + PageNum + ".TIF"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elif len(PageNum) == 2:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; PlatLink = "\\\\" + "Covsdesrv" + '\\' + "GIS Common" + '\\' + "Plats" + '\\' + "00" + MapNum + '\\' + "00" + MapNum + "00" + PageNum + ".TIF"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elif len(PageNum) == 3:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; PlatLink = "\\\\" + "Covsdesrv" + '\\' + "GIS Common" + '\\' + "Plats" + '\\' + "00" + MapNum + '\\' + "00" + MapNum + "0" + PageNum + ".TIF"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AND&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if (!PAGE!) = 1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PlatLink = "\\\\" + "Covsdesrv" + '\\' + "GIS Common" + '\\' + "Plats" + '\\' + "00" + str(!MAP_BOOK!) + '\\' + "00" + str(!MAP_BOOK!) + "000" + str(!PAGE!) + ".TIF"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elif (!PAGE!) = 2:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PlatLink = "\\\\" + "Covsdesrv" + '\\' + "GIS Common" + '\\' + "Plats" + '\\' + "00" + str(!MAP_BOOK!) + '\\' + "00" + str(!MAP_BOOK!) + "00" + str(!PAGE!) + ".TIF"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elif (!PAGE!) = 2:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PlatLink = "\\\\" + "Covsdesrv" + '\\' + "GIS Common" + '\\' + "Plats" + '\\' + "00" + str(!MAP_BOOK!) + '\\' + "00" + str(!MAP_BOOK!) + "0" + str(!PAGE!) + ".TIF"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;any help appreciated&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jan 2011 14:40:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349491#M1150</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2011-01-27T14:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: python field calculator issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349492#M1151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Im not sure why that isnt working but for starters you should try string substitution instead of concatentation and raw strings so you dont have to excape all those'\'. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://docs.python.org/release/2.6.6/library/stdtypes.html#string-formatting-operations"&gt;http://docs.python.org/release/2.6.6/library/stdtypes.html#string-formatting-operations&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PlatLink = r"\\Covsdesrv\GIS Common\Plats\00%s\00%s000%s.TIF"%(MapNum,MapNum,PageNum)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jan 2011 17:08:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349492#M1151</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2011-01-27T17:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: python field calculator issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349493#M1152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: frankv3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Im not sure why that isnt working but for starters you should try string substitution instead of concatentation and raw strings so you dont have to excape all those'\'. &lt;BR /&gt; &lt;BR /&gt;&lt;A href="http://docs.python.org/release/2.6.6/library/stdtypes.html#string-formatting-operations"&gt;http://docs.python.org/release/2.6.6/library/stdtypes.html#string-formatting-operations&lt;/A&gt;&lt;BR /&gt; &lt;BR /&gt;PlatLink = r"\\Covsdesrv\GIS Common\Plats\00%s\00%s000%s.TIF"%(MapNum,MapNum,PageNum)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you for the tip, i'm just learning to use this scripting language and any help is much appreciated&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jan 2011 17:28:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349493#M1152</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2011-01-27T17:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: python field calculator issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349494#M1153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: frankv3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;it is still not calculating in ArcMap, reports the Error 000989 - Python Syntax Error , this is the calculation code (saved out)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MapNum = str(!MAP_BOOK!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PageNum = str(!PAGE!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if len(PageNum) == 1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PlatLink = r"\\Covsdesrv\GIS Common\Plats\00%s000%s.TIF"%(MapNum,MapNum,PageNum)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elif len(PageNum) == 2:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PlatLink = r"\\Covsdesrv\GIS Common\Plats\00%s00%s.TIF"%(MapNum,MapNum,PageNum)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elif len(PageNum) == 3:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PlatLink = r"\\Covsdesrv\GIS Common\Plats\00%s0%s.TIF"%(MapNum,MapNum,PageNum)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;__esri_field_calculator_splitter__&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PlatLink&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;it runs fine in the IDLE window as before, anyone know what i'm doing wrong?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jan 2011 19:33:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349494#M1153</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2011-01-28T19:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: python field calculator issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349495#M1154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The code you are showing does not show indentation of the action parts of the if statements. Python is very picky about white space and there must be indentation. I'm certain when you typed it into IDLE it supplied the indentation for you automatically.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if len(PageNum) == 1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PlatLink = r"\\Covsdesrv\GIS Common\Plats\00%s000%s.TIF"%(MapNum,MapNum,PageNum )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elif len(PageNum) == 2:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PlatLink = r"\\Covsdesrv\GIS Common\Plats\00%s00%s.TIF"%(MapNum,MapNum,PageNum)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elif len(PageNum) == 3:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PlatLink = r"\\Covsdesrv\GIS Common\Plats\00%s0%s.TIF"%(MapNum,MapNum,PageNum)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jan 2011 22:11:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349495#M1154</guid>
      <dc:creator>PatrickOMalley</dc:creator>
      <dc:date>2011-01-28T22:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: python field calculator issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349496#M1155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I know I put 4 spaces in front of every line that started with PlatLink, but they don't show up in my submittal to the forum. Maybe your indentation is fine and the forum software strips off excess whitespace.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jan 2011 22:15:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349496#M1155</guid>
      <dc:creator>PatrickOMalley</dc:creator>
      <dc:date>2011-01-28T22:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: python field calculator issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349497#M1156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You have to put code in the code blocks in the html editor, select the # tool from the message posting toolbar, paste your code and the proper indentation will be maintained as in this nonsence example&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
names = ["Obi", "Bob", "Billy"]
for name in names:
&amp;nbsp; if name == "Obi":
&amp;nbsp;&amp;nbsp;&amp;nbsp; print name, "is ", True, "a", "Jedi master"
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print name, "is not a Jedi master"&amp;nbsp; 
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;don't forget to copy, compile and run the script to see if it works &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:26:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349497#M1156</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T16:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: python field calculator issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349498#M1157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: frankv3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;so, the field names go at the bottom in the Expression box and then the result goes above in the Code Block box&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;it's almost the opposite of how the VBA calculator expressions ran&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this is what works for us to calculate hyperlinks based on two fields:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def SetLink(map,page):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if len(str(page)) == 1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num0 = "000"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; elif len(str(page)) == 2:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num0 = "00"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; elif len(str(page)) == 3:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num0 = "0"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return r"\\Covsdesrv\GIS Common\Plats\00%s\00%s%s%s.TIF"%( str(map), str(map), num0, str(page))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SetLink( !MAP_BOOK!, !PAGE! )&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Feb 2011 17:59:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349498#M1157</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2011-02-04T17:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: python field calculator issue</title>
      <link>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349499#M1158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Seems unecessarily complicated. Simpler version follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def SetLink(map, page):
&amp;nbsp;&amp;nbsp;&amp;nbsp; return r"\\Covsdesrv\GIS Common\Plats\%03d\%03d%04d.TIF % (map, map, page)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:26:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-field-calculator-issue/m-p/349499#M1158</guid>
      <dc:creator>NiklasNorrthon</dc:creator>
      <dc:date>2021-12-11T16:26:49Z</dc:date>
    </item>
  </channel>
</rss>

