I have a piece of code where the goal is to search through the field names within a feature, select any field based on a specific character (in this case "z") and then use that selected field within a Field Calculator Expression. My experience with python is limited, see the code below;
for var in List_Input:
filename = os.path.splitext(os.path.basename(str(var)))[0] arcpy.Select_analysis(var, env+"\\"+filename, "") var_sel = env+"\\"+filename arcpy.AddField_management(var_sel,"VR_Rate","Double") VRField = arcpy.ListFields(var_sel,) VRField_Calc = "" for field in VRField: if "z" in field.name: VRField_Calc = field.name arcpy.CalculateField_management(var_sel,"VR_Rate", [VRField_Calc+" + 2"]) The bottom half of the code is where the issues arise. How to pass the "VRField_Calc" (field name) into the Calculate Field Expression? Thank you in advance.
أكثر...
for var in List_Input:
filename = os.path.splitext(os.path.basename(str(var)))[0] arcpy.Select_analysis(var, env+"\\"+filename, "") var_sel = env+"\\"+filename arcpy.AddField_management(var_sel,"VR_Rate","Double") VRField = arcpy.ListFields(var_sel,) VRField_Calc = "" for field in VRField: if "z" in field.name: VRField_Calc = field.name arcpy.CalculateField_management(var_sel,"VR_Rate", [VRField_Calc+" + 2"]) The bottom half of the code is where the issues arise. How to pass the "VRField_Calc" (field name) into the Calculate Field Expression? Thank you in advance.
أكثر...