<?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 stops in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246253#M66455</link>
    <description>&lt;PRE&gt;valDict.get(row[5], 25)&lt;/PRE&gt;&lt;P&gt;will try to get the key (row[5]) from the dictionary valDict. If there is no key in the dictionary, it returns the default value of 25.&lt;/P&gt;&lt;P&gt;I take it this question is is part of your other question you posted a couple weeks ago and if that is the case, you should continue in that thread because what you are trying to do with the 'decision tree' to assign percent complete is a lot more complex than this code example can handle.&lt;/P&gt;</description>
    <pubDate>Sat, 07 Jan 2023 05:17:16 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2023-01-07T05:17:16Z</dc:date>
    <item>
      <title>Update cursor stops</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246167#M66442</link>
      <description>&lt;P&gt;I am trying the following but I only get 25 in the progress field on features that have something in "Field5". It seems to stop if it encounters a blank record in Field5. What am i doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;valDict{}

with arcpy.da.UpdateCursor(table2, ["OBJECTID","Field1","Field2","Field3","Field4","Field5","Field6", "Field7", "Field8","Progress"],
                           where) as cursor:
    for row in cursor:
            try:
                if row[5] is None: #if row[5] not in (None, "", " "):
                    continue
                if row[5] in list1:
                    print ("{} is in list".format(row[0]))
                    row[9] = valDict.get(row[5]) if row[6] == "Pass" else valDict.get(row[5], 25) - 25 
                cursor.updateRow(row)
            except:
                continue&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 20:17:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246167#M66442</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-01-06T20:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: Update cursor stops</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246171#M66443</link>
      <description>&lt;P&gt;I believe there are a few things wrong with your code.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;The first line, "valDict{}", is incomplete. It looks like it's supposed to be creating an empty dictionary, but it's missing the "=", so it will throw a syntax error. It should be written as "valDict = {}".&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The "where" clause in the UpdateCursor is not defined. It should be replaced with a valid SQL WHERE clause, such as "WHERE Field1 = 'some value'"&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The "continue" statement in the "except" block will prevent any errors from being raised or logged. Instead, it would be more helpful to either log the error or raise it to be handled by an enclosing try/except block.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;See below for assistance:&lt;/P&gt;&lt;P&gt;valDict = {}&lt;/P&gt;&lt;P&gt;with arcpy.da.UpdateCursor(table2, ["OBJECTID","Field1","Field2","Field3","Field4","Field5","Field6", "Field7", "Field8","Progress"], "WHERE Field1 = 'some value'") as cursor:&lt;BR /&gt;for row in cursor:&lt;BR /&gt;try:&lt;BR /&gt;if row[5] is None: #if row[5] not in (None, "", " "):&lt;BR /&gt;continue&lt;BR /&gt;if row[5] in list1:&lt;BR /&gt;print ("{} is in list".format(row[0]))&lt;BR /&gt;row[9] = valDict.get(row[5]) if row[6] == "Pass" else valDict.get(row[5], 25) - 25&lt;BR /&gt;cursor.updateRow(row)&lt;BR /&gt;except Exception as e:&lt;BR /&gt;print(e)&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 20:28:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246171#M66443</guid>
      <dc:creator>ChrisJRoss13</dc:creator>
      <dc:date>2023-01-06T20:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Update cursor stops</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246181#M66444</link>
      <description>&lt;P&gt;The ValDict and the where do have values, I was just trying to post quickly and didn't include them.&lt;/P&gt;&lt;P&gt;I did try the exception as e: but no message gets printed.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 20:57:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246181#M66444</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-01-06T20:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Update cursor stops</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246194#M66445</link>
      <description>&lt;P&gt;Both row[5] and row[6] have blanks in the fields.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 21:22:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246194#M66445</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-01-06T21:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: Update cursor stops</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246220#M66447</link>
      <description>&lt;P&gt;At a quick glance, it appears you have indentation issues, and some missing colons.&lt;/P&gt;&lt;P&gt;the if row[5] line has another if statement in it, without colon or what to do if true.&amp;nbsp; else statement also wrong indentation and no colon.&lt;/P&gt;&lt;P&gt;Don't know if this is the issue, but would expect it to be throwing syntax errors.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;valDict{}

with arcpy.da.UpdateCursor(table2, ["OBJECTID","Field1","Field2","Field3","Field4","Field5","Field6", "Field7", "Field8","Progress"],
                           where) as cursor:
    for row in cursor:
            try:
                if row[5] is None: #if row[5] not in (None, "", " "):
                    continue
                if row[5] in list1:
                    print ("{} is in list".format(row[0]))
                    row[9] = valDict.get(row[5]) 
                if row[6] == "Pass":
                     missing what to do if true
                else:
                     valDict.get(row[5], 25) - 25 
                cursor.updateRow(row)
            except:
                continue&lt;/LI-CODE&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 22:38:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246220#M66447</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2023-01-06T22:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: Update cursor stops</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246253#M66455</link>
      <description>&lt;PRE&gt;valDict.get(row[5], 25)&lt;/PRE&gt;&lt;P&gt;will try to get the key (row[5]) from the dictionary valDict. If there is no key in the dictionary, it returns the default value of 25.&lt;/P&gt;&lt;P&gt;I take it this question is is part of your other question you posted a couple weeks ago and if that is the case, you should continue in that thread because what you are trying to do with the 'decision tree' to assign percent complete is a lot more complex than this code example can handle.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jan 2023 05:17:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-stops/m-p/1246253#M66455</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-01-07T05:17:16Z</dc:date>
    </item>
  </channel>
</rss>

