<?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 only blank, null field attributes in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/update-only-blank-null-field-attributes/m-p/1117446#M62992</link>
    <description>&lt;P&gt;I meant that I need to update Field1 and that Field1 has some attributes and also FieldA sometimes has attributes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;dict1 = dict()
with arcpy.da.SearchCursor(fc,['FieldA','COUNT','FieldB']) as cursor:
    for row in cursor:
        if row[0] not in (None, "", " "):
            dict1.setdefault(row[0],[]).append(str(row[2]))

with arcpy.da.UpdateCursor(fc,['FieldA','COUNT','Field1']) as cursor:
    for row in cursor:
         if row[2] is None:
            if row[0] not in (None, "", " "):
                row[2] = ",".join(dict1[row[0]])
                cursor.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Nov 2021 21:31:37 GMT</pubDate>
    <dc:creator>2Quiker</dc:creator>
    <dc:date>2021-11-16T21:31:37Z</dc:date>
    <item>
      <title>Update only blank, null field attributes</title>
      <link>https://community.esri.com/t5/python-questions/update-only-blank-null-field-attributes/m-p/1117376#M62987</link>
      <description>&lt;P&gt;I need to only update the fields attributes that are blank or Null, there are some attributes in Feilda and I want to skip those but I am not sure how do to do that. I have the following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;with arcpy.da.UpdateCursor(fc,['Fielda','COUNT','Field1']) as cursor:
    for row in cursor:
         if row[0] not in (None, "", " "):
            row[2] = ",".join(dict1[row[0]])
            cursor.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 18:54:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-only-blank-null-field-attributes/m-p/1117376#M62987</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2021-11-16T18:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Update only blank, null field attributes</title>
      <link>https://community.esri.com/t5/python-questions/update-only-blank-null-field-attributes/m-p/1117406#M62988</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;PRE&gt;dict1&lt;/PRE&gt;&lt;HR /&gt;where is this defined?&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 16 Nov 2021 20:21:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-only-blank-null-field-attributes/m-p/1117406#M62988</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-11-16T20:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Update only blank, null field attributes</title>
      <link>https://community.esri.com/t5/python-questions/update-only-blank-null-field-attributes/m-p/1117415#M62989</link>
      <description>&lt;P&gt;still don't know where your dict1 is defined but this code will skip the rows with records&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.UpdateCursor(fc,['Fielda','COUNT','Field1']) as cursor:
    for row in cursor:
         if row[0] not in (None, "", " "):
            row[2] = ",".join(dict1[row[0]])
            cursor.updateRow(row)             
         else:
             print("All good, nothing to do here")&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 16 Nov 2021 20:41:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-only-blank-null-field-attributes/m-p/1117415#M62989</guid>
      <dc:creator>DominicRobergeIADOT</dc:creator>
      <dc:date>2021-11-16T20:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Update only blank, null field attributes</title>
      <link>https://community.esri.com/t5/python-questions/update-only-blank-null-field-attributes/m-p/1117416#M62990</link>
      <description>&lt;P&gt;Your conditional as written is testing if the Fielda is not null so its doing the opposite of what you are wanting to do.&amp;nbsp;&lt;/P&gt;&lt;P&gt;just change your conditional:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if row[0] in [None, "", " "]:&lt;/LI-CODE&gt;&lt;P&gt;or you can filter nulls in the where clause:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.UpdateCursor(fc, ['Fielda', 'Field1'], 'Fielda IS NULL') as cursor:
   for row in cursor:
      row[1] = ",".join(dict1[row[0]])
      ...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 20:42:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-only-blank-null-field-attributes/m-p/1117416#M62990</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-11-16T20:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Update only blank, null field attributes</title>
      <link>https://community.esri.com/t5/python-questions/update-only-blank-null-field-attributes/m-p/1117446#M62992</link>
      <description>&lt;P&gt;I meant that I need to update Field1 and that Field1 has some attributes and also FieldA sometimes has attributes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;dict1 = dict()
with arcpy.da.SearchCursor(fc,['FieldA','COUNT','FieldB']) as cursor:
    for row in cursor:
        if row[0] not in (None, "", " "):
            dict1.setdefault(row[0],[]).append(str(row[2]))

with arcpy.da.UpdateCursor(fc,['FieldA','COUNT','Field1']) as cursor:
    for row in cursor:
         if row[2] is None:
            if row[0] not in (None, "", " "):
                row[2] = ",".join(dict1[row[0]])
                cursor.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 21:31:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-only-blank-null-field-attributes/m-p/1117446#M62992</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2021-11-16T21:31:37Z</dc:date>
    </item>
  </channel>
</rss>

