I have a feature class in which one field (let's call it "Field_A"), as yet empty, is to be populated by the contents of another field ("Field_B") multiplied by a certain number (I'll call it the "constant"). Would it be a good idea to simply populate Field_A using an update cursor, as follows:
rows = arcpy.UpdateCursor(InTable) for row in rows: row.Field_A = row.Field_B * constant rows.updateRow(row) del row, rows
, or do I have to use the field calculator? If I have to use the field calculator, I'm having an issue with the syntax. I defined the expression thus:
expression = "Field_A * constant"
and the code is as follows:
arcpy.CalculateField_management(InTable, "Field_A", expression)
When using CalculateField as shown, the script runs without errors, but "Field_A" is populated with zeros as a result. What am I doing wrong with CalculateField, or should I simply use an update cursor?