<?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: Trying to use dictionary key with UpdateCurosor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558120#M43623</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;put your latest iteration of your code up and I'll see if I can figure it out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the better way to see if a value is None (&amp;lt;Null&amp;gt;) you should use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is None instead of == None&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The thing you need to be sure&amp;nbsp; is you are checking for it and doing something when it is null and something else when it isn't.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; x &lt;SPAN class="keyword token"&gt;is&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; None&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
   &lt;SPAN class="keyword token"&gt;pass&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
   do something

&lt;SPAN class="comment token"&gt;#### or&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; x &lt;SPAN class="keyword token"&gt;is&lt;/SPAN&gt; None&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
   do something
&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;pass&lt;/SPAN&gt;


‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&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;See&amp;nbsp;&lt;A class="link-titled" href="https://www.quora.com/Can-you-explain-in-simple-terms-what-is-not-None-in-Python-3-x-is" title="https://www.quora.com/Can-you-explain-in-simple-terms-what-is-not-None-in-Python-3-x-is" rel="nofollow noopener noreferrer" target="_blank"&gt;Can you explain in simple terms what 'is not None' in Python 3.x is? - Quora&lt;/A&gt;&amp;nbsp; ; a guy named Troy Hoffman gives a good explanation in his comment.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 00:05:45 GMT</pubDate>
    <dc:creator>JoeBorgione</dc:creator>
    <dc:date>2021-12-12T00:05:45Z</dc:date>
    <item>
      <title>Trying to use dictionary key with UpdateCurosor</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558117#M43620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can do it with a basic arcpy.da.UpdateCurosr but I am trying to figure out how to use arcpy.da.UpdateCurosr with dictionary key.&amp;nbsp;I am trying to populate Field1 if the row is blank but if not then continue on to the next row. I have the following but I get error, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;upd_row[0] = search_feats[upd_row[1]] #FIELD_2
KeyError: 'Blah Text'
&amp;gt;&amp;gt;&amp;gt; &lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;flds = ['Field1','Field']
search_feats = {f[0]:f[1:] for f in arcpy.da.SearchCursor(fc1, flds)}


with arcpy.da.UpdateCursor(fc1, flds) as upd_cur:
     for upd_row in upd_cur:
        #if upd_row[0] is None:
        if upd_row[0] != None:
        #if upd_row[0] in ("", ' ', None):               
            upd_row[0] = search_feats[upd_row[1]] #FIELD1
            upd_cur.updateRow(upd_row)


del upd_cur‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:05:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558117#M43620</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2021-12-12T00:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use dictionary key with UpdateCurosor</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558118#M43621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the error you are getting?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is how I've done something similar in the past:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;tableFields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'SITEID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'SITE_GUID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
source &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'some\path\to\data table'&lt;/SPAN&gt;

guidDict &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;r&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&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="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; r &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;source&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;tableFields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;UpdateCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;updateTable&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;updateFields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; updateRows&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; updateRow &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; updateRows&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        keyValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; updateRow&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; keyValue &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; guidDict &lt;SPAN class="operator token"&gt;and&lt;/SPAN&gt; updateRow&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="operator token"&gt;==&lt;/SPAN&gt; None&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            updateRow&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="operator token"&gt;=&lt;/SPAN&gt; guidDict&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;keyValue&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
            updateRows&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;updateRow&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            &lt;SPAN class="keyword token"&gt;pass&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:05:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558118#M43621</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-12T00:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use dictionary key with UpdateCurosor</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558119#M43622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joe, thanks for the response. I see but after using your code and implementing my data and running the code field1 is not being populated with field2 if the fied1 rows are blank.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error I was getting was with my code was;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "D:\GIS Folder Scripts\UpdateFiledBlanks.py", line 10, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; upd_row[0] = search_feats[upd_row[1]] #FIELD_2&lt;BR /&gt;KeyError: 'Final Plat'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Oct 2020 16:57:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558119#M43622</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2020-10-09T16:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use dictionary key with UpdateCurosor</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558120#M43623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;put your latest iteration of your code up and I'll see if I can figure it out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the better way to see if a value is None (&amp;lt;Null&amp;gt;) you should use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is None instead of == None&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The thing you need to be sure&amp;nbsp; is you are checking for it and doing something when it is null and something else when it isn't.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; x &lt;SPAN class="keyword token"&gt;is&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; None&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
   &lt;SPAN class="keyword token"&gt;pass&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
   do something

&lt;SPAN class="comment token"&gt;#### or&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; x &lt;SPAN class="keyword token"&gt;is&lt;/SPAN&gt; None&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
   do something
&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;pass&lt;/SPAN&gt;


‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&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;See&amp;nbsp;&lt;A class="link-titled" href="https://www.quora.com/Can-you-explain-in-simple-terms-what-is-not-None-in-Python-3-x-is" title="https://www.quora.com/Can-you-explain-in-simple-terms-what-is-not-None-in-Python-3-x-is" rel="nofollow noopener noreferrer" target="_blank"&gt;Can you explain in simple terms what 'is not None' in Python 3.x is? - Quora&lt;/A&gt;&amp;nbsp; ; a guy named Troy Hoffman gives a good explanation in his comment.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:05:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558120#M43623</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-12T00:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use dictionary key with UpdateCurosor</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558121#M43624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;flds &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Field1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Field'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
search_feats &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;f&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="keyword token"&gt;for&lt;/SPAN&gt; f &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; flds&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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In this bit of your code, 'Field1' id becoming the dictionary key f[0].&amp;nbsp; A dictionary key cannot be blank.&amp;nbsp; Field1 should be unique, something like an object id ('OID@' for example)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:05:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558121#M43624</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-12T00:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use dictionary key with UpdateCurosor</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558122#M43625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That was my initial thought and makes sense but if Field1 is unique pass field2 and field3 to updatecursor and update field1 with field2 if filed1 is blank? I am still trying to make sense of Dictionary keys and how to loop through them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Oct 2020 20:38:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558122#M43625</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2020-10-09T20:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use dictionary key with UpdateCurosor</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558123#M43626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is what I've got, I posted the wrong one at first.&lt;/P&gt;&lt;P&gt;I get no errors but field1 row doesn't get populated with field2 is field1 row is blank.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;flds = ['field1','field2']

search_feats = {f[0]:f[1] for f in arcpy.da.SearchCursor(fc1,flds)}

with arcpy.da.UpdateCursor(fc1,flds) as upd_cur:
     for upd_row in upd_cur:
          if upd_row[1] == None:
               upd_row[1] = search_feats[upd_row[0]]
               upd_cur.updateRow(upd_row)  
          else:
               pass
del upd_cur  ‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:05:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558123#M43626</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2021-12-12T00:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use dictionary key with UpdateCurosor</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558124#M43627</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;I get no errors but field1 row doesn't get populated with field2 if field1 row is blank.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is huge difference between None and a Blank or Empty field.&amp;nbsp; The None value, which is python's way of denoting the &amp;lt;Null&amp;gt; value is a specific value: NULL.&amp;nbsp; A blank or empty field is not null; it has at least one space in it.&amp;nbsp; Numeric and date fields can't have a space in them, so they are Null by default.&amp;nbsp; However, a space in a text field (or fifty spaces) will torpedo your use of &lt;STRONG&gt;is None&lt;/STRONG&gt; or &lt;STRONG&gt;== None&lt;/STRONG&gt; every time.&amp;nbsp; Check your data!&amp;nbsp; I can't tell you how many calories I've burned converting blank fields to Null values. ( But I'm still pudgy...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dictionaries are relatively simple once you get used to using them.&amp;nbsp; They are in the form of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Key:Value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All the keys must be unique, and you can only have one value per key. Remember though, the value can be a tuple so that's&amp;nbsp;a way to cheat the one key one value rule. (You can 'nest' dictionaries too, but that gets too weird for me.) Think about a any table in a database; it's basically a dictionary.&amp;nbsp; It has an object id (key) and a tuple of values:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{1:('feild1','field2', 'field...n'),&lt;/P&gt;&lt;P&gt;2:&lt;SPAN&gt;('feild1','field2', 'field...n'),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;3:&lt;SPAN&gt;('feild1','field2', 'field...n')}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;etc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The trick with dictionaries and update cursors is being able to identify the unique key and extract the value associated with that unique key that you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Oct 2020 21:55:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558124#M43627</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2020-10-09T21:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use dictionary key with UpdateCurosor</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558125#M43628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I created a quick feature for illustration.&amp;nbsp; It contains the following:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="510711" alt="" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/510711_Quicker1.png" /&gt;&lt;/P&gt;&lt;P&gt;To copy the value from Field2 to Field1 using a dictionary, I modified your code and added some explanation:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fc1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'DictionaryTest'&lt;/SPAN&gt;

flds &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'OBJECTID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Field1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Field2'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# for clarity, put f[1:] in parenthsis - this will be a tuple&lt;/SPAN&gt;
search_feats &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;f&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="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; f &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; flds&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Produces this dictionary: {1: (u'', u'AA2'), 2: (u'bb1', u'BB2'), 3: (None, u'CC2')}&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# key = 1, value[0] = empty string, value[1] = 'AA2'&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# key = 2, value[0] = bb1, value[1] = 'BB2'&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# key = 3, value[0] = None/Null, value[1] = 'CC2'&lt;/SPAN&gt;



&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;UpdateCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; flds&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; upd_cur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; upd_row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; upd_cur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;

        &lt;SPAN class="comment token"&gt;# if upd_row[0] == None:&lt;/SPAN&gt;
        &lt;SPAN class="comment token"&gt;# this is the OBJECTID, it should always have a value&lt;/SPAN&gt;

        &lt;SPAN class="comment token"&gt;#  is the OBJECTID in the search_feats dictionary?&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; upd_row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; search_feats&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;keys&lt;SPAN class="punctuation 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="comment token"&gt;# upd_row[1] is 'Field1' and upd_row[2] is 'Field2'&lt;/SPAN&gt;
            &lt;SPAN class="comment token"&gt;# search_feats[upd_row[0]] is the dictionary key, 'Field2' is the second value of the dictionary [1]&lt;/SPAN&gt;

            upd_row&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="operator token"&gt;=&lt;/SPAN&gt; search_feats&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;upd_row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation 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;

            upd_cur&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;upd_row&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

        &lt;SPAN class="comment token"&gt;# OBJECTID not in dictionary&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            &lt;SPAN class="keyword token"&gt;pass&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The result is:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="510712" alt="" class="jive-emoji jive-image image-2 j-img-original" src="https://community.esri.com/legacyfs/online/510712_Quicker2.png" /&gt;&lt;/P&gt;&lt;P&gt;Field1 now contains the same values as Field2.&amp;nbsp; For something this simple, I wouldn't use a dictionary.&amp;nbsp; It would work best in place of joining two features on a common field to copy values from one feature to the other.&amp;nbsp; It may also be helpful in some other cases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:05:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558125#M43628</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-12T00:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use dictionary key with UpdateCurosor</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558126#M43629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG style="background-color: #ffffff; "&gt;It would work best in place of joining two features on a common field to copy values from one feature to the other.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;A href="https://community.esri.com/migrated-users/177236"&gt;2 Quiker&lt;/A&gt;‌, that is the basis of the infamous &lt;A _jive_internal="true" href="https://community.esri.com/blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-dictionaries"&gt;Richard Fairhurst post&lt;/A&gt;&amp;nbsp;which in my view is a classic.&amp;nbsp; It's because of his post that I got into using dictionaries.&amp;nbsp; As &lt;A href="https://community.esri.com/migrated-users/34565"&gt;Randy Burton&lt;/A&gt;&amp;nbsp;suggests, they are helpful in other instances as well.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Oct 2020 22:07:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558126#M43629</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2020-10-09T22:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use dictionary key with UpdateCurosor</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558127#M43630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, I think what is hold me up is that there are some 'Nulls' in field2.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Oct 2020 22:44:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558127#M43630</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2020-10-09T22:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use dictionary key with UpdateCurosor</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558128#M43631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome, thanks for the explanation on this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Oct 2020 22:47:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-use-dictionary-key-with-updatecurosor/m-p/558128#M43631</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2020-10-09T22:47:38Z</dc:date>
    </item>
  </channel>
</rss>

