<?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: Using Python Dictionaries to Assign Feature Values  in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413893#M32587</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There may be issues further down in your code, like not using Python 'in' correctly, but fundamentally the error you are encountering now has to do with columns/fields.&amp;nbsp; The error is straightforward, i.e., there is a column name being passed to the cursor that doesn't exist in the feature class or feature layer.&amp;nbsp; So, focus on verifying the columns and column names.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Apr 2020 17:50:39 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2020-04-23T17:50:39Z</dc:date>
    <item>
      <title>Using Python Dictionaries to Assign Feature Values</title>
      <link>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413889#M32583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to use python dictionaries to change the feature values of different fields.&lt;/P&gt;&lt;P&gt;I created the script below to change the feature values of a field called "DOR_UC" and as you can see there is a list of other fields where I need to do something similar - that's why there is a long list of other fields.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

&lt;SPAN class="comment token"&gt;# script to assign values to features in one field based on a value in the dictionary&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"D:\APRX_MXDS\USA_Parcels_2019_Project\test_featureclasses.gdb"&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;overwriteOutput &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# feature class&lt;/SPAN&gt;
fc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"testing_fc"&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# printing all fields in fc&lt;/SPAN&gt;
fields &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;name &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;ListFields&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# dictionary&lt;/SPAN&gt;
uses &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"000"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Vacant Residential – with/without extra features"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"001"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Single Family"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"002"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Mobile Homes"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
            &lt;SPAN class="string token"&gt;"003"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Multi-family - 10 units or more"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
            &lt;SPAN class="string token"&gt;"004"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Condominiums"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
            &lt;SPAN class="string token"&gt;"005"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Cooperatives"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
            &lt;SPAN class="string token"&gt;"006"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Retirement Homes not eligible for exemption"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
            &lt;SPAN class="string token"&gt;"007"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Miscellaneous Residential (migrant camps, boarding homes, etc.)"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
            &lt;SPAN class="string token"&gt;"008"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Multi-family - fewer than 10 units"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
            &lt;SPAN class="string token"&gt;"009"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Residential Common Elements/Areas"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
            &lt;SPAN class="string token"&gt;"010"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Vacant Commercial - with/without extra features"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
            &lt;SPAN class="string token"&gt;"011"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Stores, one story"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
            &lt;SPAN class="string token"&gt;"012"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Mixed use - store and office or store and residential combination"&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;# dictionary keys to list&lt;/SPAN&gt;
usesKey &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uses&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;# dictionary values to list&lt;/SPAN&gt;
usesvalues &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uses&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;values&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;# List of fields&lt;/SPAN&gt;
fields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"BAS_STRT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"DOR_UC"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"TEST"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"PAR_SPLT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"CONST_CLASS"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"IMP_QUAL"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"M_PAR_SAL1"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"QUAL_CD1"&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;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; usesKey &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; 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="punctuation token"&gt;:&lt;/SPAN&gt;
            row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; usesvalues
        cursor&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateRow&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;/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;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;&amp;nbsp;Field DOR_UC currently has some codes that I need to convert into a sentence.&lt;/P&gt;&lt;P&gt;See image below for fc attribute's table:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" height="413" src="https://community.esri.com/legacyfs/online/489720_pastedImage_1.jpg" width="502" /&gt;&lt;/P&gt;&lt;P&gt;Each of those codes has a meaning in the form of a sentence. I need to assign their meaning and delete the codes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To do this I've created a dictionary where the key is the code and the value is the sentence (See&amp;nbsp;attached csv).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To start testing the script I created a field called "TEST" where I want to put the value part of the dictionary.&lt;/P&gt;&lt;P&gt;So the code would go something like this:&lt;/P&gt;&lt;P&gt;If a feature in field DOR_UC is equal to 000 then the feature value in field TEST would be "Vacant Residential&amp;nbsp; - with/without extra features".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I try to run the code I am getting this first error:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Traceback (most recent call last):
  File "D:/APRX_MXDS/USA_Parcels_2019_Project/Scripts/Dictionary Key() method_2.py", line 44, in &amp;lt;module&amp;gt;
    for row in cursor:
RuntimeError: A column was specified that does not exist.&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The weird thing is that I have both of the columns.&lt;/P&gt;&lt;P&gt;Not sure how to solve this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, not sure if the overall code has more errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could someone help me with this? I need to finish this today and I have no idea on how to continue.&lt;/P&gt;&lt;P&gt;thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:46:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413889#M32583</guid>
      <dc:creator>NataliaGutierrez1</dc:creator>
      <dc:date>2021-12-11T18:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Dictionaries to Assign Feature Values</title>
      <link>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413890#M32584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm guessing you've put the field list in for our benefit? It doesn't look light theres anything wrong with that fieldlist, but you may want to try baseName.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from the actual cursor, it looks like you're using the in statement the wrong way around, and also trying to set the output to a list of values which won't work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2020 17:11:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413890#M32584</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-04-23T17:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Dictionaries to Assign Feature Values</title>
      <link>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413891#M32585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can You explain a little bit further what you mean by baseName?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, should I write&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if row[1] in useskey:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2020 17:30:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413891#M32585</guid>
      <dc:creator>NataliaGutierrez1</dc:creator>
      <dc:date>2020-04-23T17:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Dictionaries to Assign Feature Values</title>
      <link>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413892#M32586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know if field.name is returning aliases, im not sure on that one. you could use a wildcard if it becomes a sticking point '*'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;yes,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if row[1] in useskey:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; row[2] = uses[row[1]]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this sets a test that the DOR_UC field value is in the key list, then sets "TEST" to the dictionary key value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2020 17:50:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413892#M32586</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-04-23T17:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Dictionaries to Assign Feature Values</title>
      <link>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413893#M32587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There may be issues further down in your code, like not using Python 'in' correctly, but fundamentally the error you are encountering now has to do with columns/fields.&amp;nbsp; The error is straightforward, i.e., there is a column name being passed to the cursor that doesn't exist in the feature class or feature layer.&amp;nbsp; So, focus on verifying the columns and column names.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2020 17:50:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413893#M32587</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-04-23T17:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Dictionaries to Assign Feature Values</title>
      <link>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413894#M32588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I understand that is the error but the column name is correct and it exists in my feature class.&lt;/P&gt;&lt;P&gt;I even include a line of code in my script that prints all of the field names. When I run the line of code it prints out the field names that supposedly don't exist.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2020 18:49:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413894#M32588</guid>
      <dc:creator>NataliaGutierrez1</dc:creator>
      <dc:date>2020-04-23T18:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Dictionaries to Assign Feature Values</title>
      <link>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413895#M32589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I even include the image containing the field/column name in the attribute table of my feature class.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2020 18:50:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413895#M32589</guid>
      <dc:creator>NataliaGutierrez1</dc:creator>
      <dc:date>2020-04-23T18:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Dictionaries to Assign Feature Values</title>
      <link>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413896#M32590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/345701" target="_blank"&gt;Natalia&amp;nbsp;&lt;/A&gt;- your use of list comprehension on line 12 is impressive.&amp;nbsp; I think your use of the 'in' statement on line 39 is&amp;nbsp;problematic as &lt;A href="https://community.esri.com/migrated-users/3420" target="_blank"&gt;Joshua&amp;nbsp;&lt;/A&gt;suggests:&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; usesKey &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; 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="punctuation token"&gt;:&lt;/SPAN&gt;
    row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; usesvalues‍‍‍‍&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;You have defined usesKey as a list of all the keys in your dictionary. That list looks something like this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;['000', '001', 002', ..... '012']‍‍&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;&lt;/P&gt;&lt;P&gt;I think you may mean this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;if row[1] in usesKey:
&amp;nbsp;&amp;nbsp;&amp;nbsp; do something....‍‍‍‍&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;&lt;/P&gt;&lt;P&gt;Similarly, you set usesvalues to a list as well.&amp;nbsp; Do you want to&amp;nbsp; set the value of Test to that complete list?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My guess is you do not, but rather you want to set the value of Test to the value associated to that given key in your dictionary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming that my guess is correct, you can skip the lists and your code could look like:&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;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;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        keyValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; 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="keyword token"&gt;if&lt;/SPAN&gt; keyValue &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; uses&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; uses&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;get&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;keyValue&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
            cursor&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
&lt;SPAN class="comment token"&gt;# more succinctly:&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;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        keyValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; 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="keyword token"&gt;if&lt;/SPAN&gt; keyValue &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; uses&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; uses&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;
            cursor&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateRow&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;/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;the logic is fairly simple:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set the keyValue variable value to what is in DOR_UC field for the given position of the cursor&lt;/P&gt;&lt;P&gt;look for that keyValue in the uses dictionary&lt;/P&gt;&lt;P&gt;if it is in the dictionary &lt;EM&gt;get the associated Value to that Key&lt;/EM&gt; and update the TEST field with that value&lt;/P&gt;&lt;P&gt;Give this a try and see if it works for you...&lt;/P&gt;&lt;P&gt;see:&amp;nbsp;&lt;A class="link-titled" href="https://www.geeksforgeeks.org/get-method-dictionaries-python/" title="https://www.geeksforgeeks.org/get-method-dictionaries-python/" rel="nofollow noopener noreferrer" target="_blank"&gt;Get() method for dictionaries in Python - GeeksforGeeks&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The more succinct way is helpful if your dictionary keys have multiple values; here we are getting the first (and only value) of the given key...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:46:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413896#M32590</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-11T18:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Dictionaries to Assign Feature Values</title>
      <link>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413897#M32591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Joe for your response.&lt;/P&gt;&lt;P&gt;I was able to run the code and it worked! I now understand how dictionaries work in ArcGIS.&lt;/P&gt;&lt;P&gt;This was extremely helpful.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2020 22:02:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413897#M32591</guid>
      <dc:creator>NataliaGutierrez1</dc:creator>
      <dc:date>2020-04-23T22:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Dictionaries to Assign Feature Values</title>
      <link>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413898#M32592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm glad it worked for you.&amp;nbsp; Using dictionaries is one of those tools you don't use every day in ArcGIS, but when you need them, they are great.&amp;nbsp; Be sure and keep little tricks like these somewhere on your computer; I keep a&amp;nbsp;directory called 'PythonDevelopment' where I archive 'stuff' that I've learned; that's where the code I shared came from...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2020 22:16:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413898#M32592</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2020-04-23T22:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Dictionaries to Assign Feature Values</title>
      <link>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413899#M32593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;that's a great idea! I've been saving every python script in the same folder but there are so many by now that it is getting very hard to find what I've done in the past.&lt;/P&gt;&lt;P&gt;I'll make sure to create a "Python Development" folder as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2020 22:49:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-dictionaries-to-assign-feature-values/m-p/413899#M32593</guid>
      <dc:creator>NataliaGutierrez1</dc:creator>
      <dc:date>2020-04-23T22:49:02Z</dc:date>
    </item>
  </channel>
</rss>

