Is it possible to use Field Calculator in ArcGIS to add text to a new field based on an if in statement?
Example: In an attribute table I have a some fields called !X!, !Y!, !Z! where "A (xx%)", "B (xx%)", "C (xx%)", "D (xx%)" are the data.
The data can be found in any field but does not have to.
I would like to use python in some form so that once I have created a New Field, I can calculate if A in !X!
copy A in !X! to New Field then continue this through !Y! and !Z!.
I believe outside of Field Calculator this will involve If in statements followed by arcpy.da.insertcursor() but I'm pretty stumped at the moment.
I hope this is clear…thanks for any help and comments!
Best Answer
Your question is a bit unclear. I try to explain to you what this script does:
You have a
column A
and acolumn B
. Depending on the values incolumn A
we populate the empty fields inColumn B
.Make sure you chose in
Expression
Python. make also sure you get your indentation right (four spaces in front of theif
,elif
andelse
statement and eight spaces in front of thereturn
If you want to populate the
Column B
with aString
, just add "" to your return values.Hope that helps.