<?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 Populate empty/black rows from an existing field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/populate-empty-black-rows-from-an-existing-field/m-p/1130986#M63406</link>
    <description>&lt;P&gt;I have the following but It's only works to populate for Field1, I would like to populate Field1 blanks or Nulls with Field2 attributes and Field2 blanks or nulls with Field1. I have the the following but it only works to populate Field1..&lt;/P&gt;&lt;P&gt;Maybe I am going about this the wrong way?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;flds = ['FID', 'Field1','Field2'] # FID shapefile, OID geodatabase

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] in search_feats.keys():
               if upd_row[1] == None:
                    upd_row[1] = search_feats[upd_row[0]][1]
                    upd_cur.updateRow(upd_row) 
               else: 
                    pass
del upd_cur  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jan 2022 20:09:01 GMT</pubDate>
    <dc:creator>CCWeedcontrol</dc:creator>
    <dc:date>2022-01-05T20:09:01Z</dc:date>
    <item>
      <title>Populate empty/black rows from an existing field</title>
      <link>https://community.esri.com/t5/python-questions/populate-empty-black-rows-from-an-existing-field/m-p/1130986#M63406</link>
      <description>&lt;P&gt;I have the following but It's only works to populate for Field1, I would like to populate Field1 blanks or Nulls with Field2 attributes and Field2 blanks or nulls with Field1. I have the the following but it only works to populate Field1..&lt;/P&gt;&lt;P&gt;Maybe I am going about this the wrong way?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;flds = ['FID', 'Field1','Field2'] # FID shapefile, OID geodatabase

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] in search_feats.keys():
               if upd_row[1] == None:
                    upd_row[1] = search_feats[upd_row[0]][1]
                    upd_cur.updateRow(upd_row) 
               else: 
                    pass
del upd_cur  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 20:09:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populate-empty-black-rows-from-an-existing-field/m-p/1130986#M63406</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2022-01-05T20:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Populate empty/black rows from an existing field</title>
      <link>https://community.esri.com/t5/python-questions/populate-empty-black-rows-from-an-existing-field/m-p/1131097#M63410</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Try this code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.UpdateCursor(fc1,flds) as upd_cur:
    for upd_row in upd_cur:
        updated = False
        if upd_row[1] == None:
            upd_row[1] = upd_row[0]
            updated = True
        if upd_row[0] == None:
            upd_row[0] = upd_row[1]
            updated = True
        if updated == True:
            upd_cur.updateRow(upd_row)&lt;/LI-CODE&gt;&lt;P&gt;To speed up process you can add whereclause parameter to your UpdateCursor to check is one of fields is None or empty&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 06:36:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populate-empty-black-rows-from-an-existing-field/m-p/1131097#M63410</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-01-06T06:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Populate empty/black rows from an existing field</title>
      <link>https://community.esri.com/t5/python-questions/populate-empty-black-rows-from-an-existing-field/m-p/1131357#M63421</link>
      <description>&lt;P&gt;Thank you I appreciate the replay. I do have something similar with a arcpy.da.UpdateCurosr. I was trying to see how it would be done with a dictionary key.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was think of adding another "if" but I am not 100% sure if I am understand the dictionary keys right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.UpdateCursor(fc1,flds) as upd_cur:
     for upd_row in upd_cur:
          if upd_row[0] in search_feats.keys():
               if upd_row[1] == None:
                    upd_row[1] = search_feats[upd_row[0]][1]
               if upd_row[2] == None:
                    upd_row[2] = search_feats[upd_row[0]][0]
                    upd_cur.updateRow(upd_row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 20:30:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populate-empty-black-rows-from-an-existing-field/m-p/1131357#M63421</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2022-01-06T20:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: Populate empty/black rows from an existing field</title>
      <link>https://community.esri.com/t5/python-questions/populate-empty-black-rows-from-an-existing-field/m-p/1131388#M63426</link>
      <description>&lt;P&gt;my indentation on line 8 was incorrect.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.UpdateCursor(fc, flds) as upd_cur:
    for upd_row in upd_cur:
        if upd_row[0] in search_feats.keys():
            if upd_row[1] in ("", ' ', None):
                upd_row[1] = search_feats[upd_row[0]][1]
            if upd_row[2] in ("", ' ', None):
                upd_row[2] = search_feats[upd_row[0]][0]
            upd_cur.updateRow(upd_row)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 06 Jan 2022 20:39:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/populate-empty-black-rows-from-an-existing-field/m-p/1131388#M63426</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2022-01-06T20:39:07Z</dc:date>
    </item>
  </channel>
</rss>

