<?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: Bugs in script to populate an empty attribute field in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196262#M676</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: mzcoyle&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As Amy and Matt pointed out, you are using the wrong equal operator for conditionals. Another option is to use a dictionary which can remove the need for conditionals completely, as well as making your code more easily extensible if you plan on adding additional classifications in the future.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;curs_dict = {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Grass": "Short",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Trees": "Tall",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Urban": "N/A"}

for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = curs_dict[row[0]]
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 09:48:21 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-12-11T09:48:21Z</dc:date>
    <item>
      <title>Bugs in script to populate an empty attribute field</title>
      <link>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196259#M673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: sellingfloe&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a copy of my script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]26766[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am attempting to populate a blank field (Veg_Height) in my shapefile attribute table with text of my own choosing depending on the value in field Class_name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;e.g. if Class_name = "Grass", change the blank Veg_Height field to "Short", if Class_name = "Trees", change the blank Veg_Height field to "Tall" etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, at the moment, I keep getting errors when I try to run this in model builder. Can anyone suggest any changes I could make?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks &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>Fri, 16 Aug 2013 21:36:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196259#M673</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-08-16T21:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Bugs in script to populate an empty attribute field</title>
      <link>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196260#M674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Here is a copy of my script.&lt;BR /&gt;&lt;BR /&gt;[ATTACH=CONFIG]26766[/ATTACH]&lt;BR /&gt;&lt;BR /&gt;I am attempting to populate a blank field (Veg_Height) in my shapefile attribute table with text of my own choosing depending on the value in field Class_name.&lt;BR /&gt;&lt;BR /&gt;e.g. if Class_name = "Grass", change the blank Veg_Height field to "Short", if Class_name = "Trees", change the blank Veg_Height field to "Tall" etc.&lt;BR /&gt;&lt;BR /&gt;Unfortunately, at the moment, I keep getting errors when I try to run this in model builder. Can anyone suggest any changes I could make?&lt;BR /&gt;&lt;BR /&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also might try writing your if statement like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

if row[0] == "Trees":
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = "Tall"

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT: Deleted first comment&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:48:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196260#M674</guid>
      <dc:creator>AmyKlug</dc:creator>
      <dc:date>2021-12-11T09:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Bugs in script to populate an empty attribute field</title>
      <link>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196261#M675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: msayler&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The '=' is used for assignment. Since you're doing a comparison, you need to use the 'equal to' operator instead, '=='.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i.e.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if row[0] == "Grass":
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = "Short"&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196261#M675</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T09:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Bugs in script to populate an empty attribute field</title>
      <link>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196262#M676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: mzcoyle&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As Amy and Matt pointed out, you are using the wrong equal operator for conditionals. Another option is to use a dictionary which can remove the need for conditionals completely, as well as making your code more easily extensible if you plan on adding additional classifications in the future.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;curs_dict = {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Grass": "Short",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Trees": "Tall",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Urban": "N/A"}

for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = curs_dict[row[0]]
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:48:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196262#M676</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T09:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: Bugs in script to populate an empty attribute field</title>
      <link>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196263#M677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks so much!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 17:06:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196263#M677</guid>
      <dc:creator>KerryThomas</dc:creator>
      <dc:date>2013-08-19T17:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Bugs in script to populate an empty attribute field</title>
      <link>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196264#M678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: curtvprice&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Here is a copy of my script.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[thread=48475]How to post Python code[/thread]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 21:06:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/bugs-in-script-to-populate-an-empty-attribute/m-p/196264#M678</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-08-19T21:06:40Z</dc:date>
    </item>
  </channel>
</rss>

