<?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:  FieldCalculate Feature Class Attribute values by matching existing field values to dictionary in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37490#M192</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Edited code. I have dropped the legacy cursor and picked ArcPy cursors later in the code. Thanks&lt;/P&gt;&lt;P&gt;I use gc in a later section of the code which is running well. Have however edited to put it to immediate use in this section.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why I used&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;dictio&lt;I&gt; is because it didnt matter whether I picked A OR AAA. I however have modified to ensure it picks the entire dictionary value say AAA OR DDD. Still not successful. My output&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;SPAN style="background-color: #ffffff;"&gt;gid = 'AAA'&lt;BR /&gt;a&lt;BR /&gt;gid = 'CCC'&lt;BR /&gt;a&lt;BR /&gt;gid = 'BBB'&lt;BR /&gt;a&lt;BR /&gt;gid = 'DDD'&lt;BR /&gt;a&lt;BR /&gt;gid = 'AAA'&lt;BR /&gt;c&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;whereeas my desired result is&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;gid = 'AAA'&lt;BR /&gt;a&lt;BR /&gt;gid = 'CCC'&lt;BR /&gt;c&lt;BR /&gt;gid = 'BBB'&lt;BR /&gt;b&lt;BR /&gt;gid = 'DDD'&lt;BR /&gt;d&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and these values should be written in the attribute table. At the moment, its writing d in all the rows.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Mar 2019 22:01:31 GMT</pubDate>
    <dc:creator>WilliamKalande</dc:creator>
    <dc:date>2019-03-05T22:01:31Z</dc:date>
    <item>
      <title>FieldCalculate Feature Class Attribute values by matching existing field values to dictionary</title>
      <link>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37486#M188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I have a dictionary whose keys also appear are attribute values in a fc_1.&lt;/P&gt;&lt;P&gt;In the code below, I use the dictionary&amp;nbsp;values to select by attribute rows (gid) in fc_1 with intention of writing the dictionary keys into another field in&amp;nbsp;&lt;SPAN&gt;fc_1&lt;/SPAN&gt; using&amp;nbsp;arcpy.SelectLayerByAttribute_management.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This only writes the last key in the dictionary against all the selected values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import arcpy

arcpy.env.workspace = r'home\delete\cccgdb.gdb'
gc = 'fc_1'
field ='FIDF'
dictio={"a": "AAA", "b": "BBB", "c": "CCC", "d": "DDD"}
fc_1_lyr = arcpy.MakeFeatureLayer_management(gc, "fc_1_lyr")
for i in dictio.keys():
&amp;nbsp; &amp;nbsp; &amp;nbsp;for j in dictio.values():
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#print (j)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;whereClause = "gid = '%s'"%j
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print (whereClause)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;act = arcpy.SelectLayerByAttribute_management(fc_1_lyr, 'NEW_SELECTION', whereClause)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  expression ='%s'%i
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print(expression)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;arcpy.CalculateField_management(act, field, expression)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  arcpy.SelectLayerByAttribute_management(fc_1_lyr, "CLEAR_SELECTION")


print ('memaliza')‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:26:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37486#M188</guid>
      <dc:creator>WilliamKalande</dc:creator>
      <dc:date>2021-12-10T21:26:56Z</dc:date>
    </item>
    <item>
      <title>Re:  FieldCalculate Feature Class Attribute values by matching existing field values to dictionary</title>
      <link>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37487#M189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For starters, format your text so it can be read: the lines in your nested for loop don't appear to be indented correctly (or are they?).&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2019 13:37:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37487#M189</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2019-03-05T13:37:35Z</dc:date>
    </item>
    <item>
      <title>Re:  FieldCalculate Feature Class Attribute values by matching existing field values to dictionary</title>
      <link>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37488#M190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Edited. Well indented in code. Didnt paste well in here&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2019 13:55:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37488#M190</guid>
      <dc:creator>WilliamKalande</dc:creator>
      <dc:date>2019-03-05T13:55:28Z</dc:date>
    </item>
    <item>
      <title>Re:  FieldCalculate Feature Class Attribute values by matching existing field values to dictionary</title>
      <link>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37489#M191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please read &lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting?sr=search&amp;amp;searchId=d5742ea6-9b0b-40f2-a083-9fbbc0d31348&amp;amp;searchIndex=3" target="_blank"&gt;/blogs/dan_patterson/2016/08/14/script-formatting?sr=search&amp;amp;searchId=d5742ea6-9b0b-40f2-a083-9fbbc0d31348&amp;amp;searchIndex=3&lt;/A&gt;‌, or watch the video &lt;A href="https://community.esri.com/blogs/sergent/2015/02/18/formatting-your-code-in-geonet-for-the-visual-learner?sr=search&amp;amp;searchId=d5742ea6-9b0b-40f2-a083-9fbbc0d31348&amp;amp;searchIndex=2" target="_blank"&gt;/blogs/sergent/2015/02/18/formatting-your-code-in-geonet-for-the-visual-learner?sr=search&amp;amp;searchId=d5742ea6-9b0b-40f2-a083-9fbbc0d31348&amp;amp;searchIndex=2&lt;/A&gt;‌.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Formatting your original code snippet:&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="keyword token"&gt;from&lt;/SPAN&gt; arcpy &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; SearchCursor
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;'home\delete\cccgdb.gdb'&lt;/SPAN&gt;
gc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'fc_1'&lt;/SPAN&gt;
field &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'FIDF'&lt;/SPAN&gt;
dictio&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"a"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"AAA"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"b"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"BBB"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"c"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"CCC"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"d"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"DDD"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
fc_1_lyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeFeatureLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"fc_1"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"fc_1_lyr"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; dictio&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="keyword token"&gt;for&lt;/SPAN&gt; j &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; dictio&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
         &lt;SPAN class="comment token"&gt;#print (j)&lt;/SPAN&gt;
         whereClause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"gid = '%s'"&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;%&lt;/SPAN&gt;j
         &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;whereClause&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
         act &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc_1_lyr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'NEW_SELECTION'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; whereClause&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
         expression &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'%s'&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;%&lt;/SPAN&gt;i
         &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;expression&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
         arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CalculateField_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;act&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; expression&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
         arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc_1_lyr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"CLEAR_SELECTION"&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;&lt;SPAN class="string token"&gt;'memaliza'&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some questions/comments:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;You are importing SearchCursor but are not using it.&amp;nbsp; If you are using ArcPy cursors somewhere later in the code, I suggest using &lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/data-access/searchcursor-class.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/data-access/searchcursor-class.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;SearchCursor—Data Access module | ArcGIS Desktop&lt;/A&gt; instead of the legacy cursor.&lt;/LI&gt;&lt;LI&gt;You define a &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;gc&lt;/SPAN&gt; variable but never use it.&lt;/LI&gt;&lt;LI&gt;I am not sure if Line #9 is doing what you think, or maybe I don't understand what you are trying to do.&amp;nbsp; Since your dictionary is storing strings, &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;dictio&lt;I&gt;&lt;/I&gt;&lt;/SPAN&gt; will return a string and &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;for j&lt;/SPAN&gt; will loop over each letter in the string.&amp;nbsp; Do you really want to create 3 identical WHERE clauses, e.g., &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;gid = 'A'&lt;/SPAN&gt;, &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;gid = 'A'&lt;/SPAN&gt;, &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;gid = 'A'&lt;/SPAN&gt; ?&lt;/LI&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:26:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37489#M191</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-10T21:26:59Z</dc:date>
    </item>
    <item>
      <title>Re:  FieldCalculate Feature Class Attribute values by matching existing field values to dictionary</title>
      <link>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37490#M192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Edited code. I have dropped the legacy cursor and picked ArcPy cursors later in the code. Thanks&lt;/P&gt;&lt;P&gt;I use gc in a later section of the code which is running well. Have however edited to put it to immediate use in this section.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why I used&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;dictio&lt;I&gt; is because it didnt matter whether I picked A OR AAA. I however have modified to ensure it picks the entire dictionary value say AAA OR DDD. Still not successful. My output&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;SPAN style="background-color: #ffffff;"&gt;gid = 'AAA'&lt;BR /&gt;a&lt;BR /&gt;gid = 'CCC'&lt;BR /&gt;a&lt;BR /&gt;gid = 'BBB'&lt;BR /&gt;a&lt;BR /&gt;gid = 'DDD'&lt;BR /&gt;a&lt;BR /&gt;gid = 'AAA'&lt;BR /&gt;c&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;whereeas my desired result is&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;gid = 'AAA'&lt;BR /&gt;a&lt;BR /&gt;gid = 'CCC'&lt;BR /&gt;c&lt;BR /&gt;gid = 'BBB'&lt;BR /&gt;b&lt;BR /&gt;gid = 'DDD'&lt;BR /&gt;d&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and these values should be written in the attribute table. At the moment, its writing d in all the rows.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2019 22:01:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37490#M192</guid>
      <dc:creator>WilliamKalande</dc:creator>
      <dc:date>2019-03-05T22:01:31Z</dc:date>
    </item>
    <item>
      <title>Re:  FieldCalculate Feature Class Attribute values by matching existing field values to dictionary</title>
      <link>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37491#M193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try the following structure:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; dictio&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"a"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"AAA"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"b"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"BBB"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"c"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"CCC"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"d"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"DDD"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; k&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; v &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; dictio&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;items&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="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;     whereClause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"gid = '%s'"&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;%&lt;/SPAN&gt;v
&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;print&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;whereClause&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="punctuation token"&gt;.&lt;/SPAN&gt;     expression &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'%s'&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;%&lt;/SPAN&gt;k
&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;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;expression&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="punctuation token"&gt;.&lt;/SPAN&gt;
gid &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'AAA'&lt;/SPAN&gt;
a
gid &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'BBB'&lt;/SPAN&gt;
b
gid &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'CCC'&lt;/SPAN&gt;
c
gid &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'DDD'&lt;/SPAN&gt;
d
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:27:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37491#M193</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-10T21:27:02Z</dc:date>
    </item>
    <item>
      <title>Re:  FieldCalculate Feature Class Attribute values by matching existing field values to dictionary</title>
      <link>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37492#M194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. Edited as below. Working well.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import arcpy
arcpy.env.workspace = r'home\Desktop\delete\cccgdb.gdb'
gc = 'fc_1'
field =['FIDF', 'gid']
dictio={"a": "AAA", "b": "BBB", "c": "CCC", "d": "DDD"}
fc_1_lyr = arcpy.MakeFeatureLayer_management(gc, "fc_1_lyr")
for k, v in dictio.items():
        whereClause = '%s'%v
        expression ='%s'%k
        with arcpy.da.UpdateCursor(gc, field) as cursor: 
            for row in cursor: 
                if row[1] == whereClause:
                   row[0] = expression
                   cursor.updateRow(row) 
 
print ('memaliza')‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:27:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/fieldcalculate-feature-class-attribute-values-by/m-p/37492#M194</guid>
      <dc:creator>wwnde</dc:creator>
      <dc:date>2021-12-10T21:27:04Z</dc:date>
    </item>
  </channel>
</rss>

