AnsweredAssumed Answered

Arcpy Update Rows with Field Name

Question asked by eddybaboy on Dec 7, 2018
Latest reply on Dec 11, 2018 by eddybaboy

I have sixteen different feature classes that mostly have the same fields that share the same domain (Pass/Fail).  I want to create a script that (1) creates a new FC bringing these all together,


      New_Feature_Class field examples: [FirstFailure], [SecondFailure], and [ThirdFailure]. 


then (2) populates rows with Field Name IF [Field] = Fail.


If a row from one of the original 16 feature classes have no fields with a 'Fail', then none of the new [Failure] fields would get populated.  


I've created the first part (below), I just can't even imagine how the second part happens.


import arcpy
from arcpy import *
import os

arcpy.env.overwriteOutput = True

database = "C:\\etc"

arcpy.env.workspace = database

fc_list = arcpy.ListFeatureClasses()

for fc in fc_list:
    fieldname = "From_FC_Name"
    arcpy.AddField_management(fc, fieldname, "TEXT", field_length = 20)
    with arcpy.da.UpdateCursor(fc, fieldname) as cursor:
        for row in cursor:
            if row[0] == None:
                row[0] = str(fc)


final_fc = "path"
arcpy.Append_management(fclist2, final_fc)