I used the 'Merge' tool to combine two feature classes (call them FC1 and FC2), and the resulting feature class (FC3) was put into a file geodatabase. I then added new fields to FC3. I want to be able to populate the newly added fields by copying the values from fields that were carried over from FC1 and FC2, and then eventually delete the old fields.I am trying to create a script that will use an update cursor to look at each row, and if there's a value for field1, then it would copy it to field3. If there's no value (aka it's null), then it would copy field2 to field3. However, the script doesn't recognize when there's a null value, and therefore it always copies from field1, even if it's an empty cell (there's never an instance where both field1 and field2 are empty).desc = arcpy.Describe(fc3)
fields = desc.fields
rows = arcpy.UpdateCursor(fc3)
for row in rows:
if row.field1 != "":
row.field3 = row.field1
else:
row.field3 = row.field2
rows.updateRow(row)
del rows
When I was testing it out, I modified the code (below) to see what arcpy is seeing, and when there were null values, it returned "None" as the value.desc = arcpy.Describe(fc3)
fields = desc.fields
rows = arcpy.UpdateCursor(fc3)
for row in rows:
if row.field1 != "":
print row.field1
else:
print row.field2
rows.updateRow(row)
del rows
I tried fixing it by changing the code to if row.field1 != "None":but it didn't change anything.Any ideas? What am I doing wrong?Thanks!