I have a dataset for utility work permits and we recently started tracking applicant email addresses so I am looking for help in writing a script for the Code Block field to do the bulk of the work of populating emails for the applicants that have more than one permit. The logic behind this would essentially be:
if ContactName = Joe Schmo
return joe.schmo@gmail.com in the email field
elif ContactName = Jane Doe
return jane.doe@yahoo.com in the email field
then if ContactName = anything else
return nothing
I would like to add more cases to cover more bases, but only spelt out those 3 for brevity. I have searched and searched already for previous examples and have tried to write several bits to try to accomplish this but to no avail. Here are the two bits I have tried to run and have gotten nowhere with both:
Email = Reclass(!Email!)
def Reclass(Email):
if (ContactName = Joe Schmo)
return joe.schmo@gmail.com
elif (ContactName = Jane Doe)
return jane.doe@yahoo.com
_____________________________________________
fieldName = "Email"
expression = "getClass(!ContactName!, Email!)"
codeblock = """def getClass(ContactName, Email):
if ContactName == 'Joe Schmo':
return "joe.schmo@gmail.com"
else:
return !Email!"""
arcpy.CalculateField_management(out_feature_class, fieldName, expression, "PYTHON_9.3", codeblock)
______________________________________________
I am using ArcPro, so I know the version of Python that it uses is different than ArcMap's, but that is literally all I know. I do not know what the differences in the syntaxes are and I do not have experience with any syntax or calling functions with Python or any scripting language. I have next to no background in scripting, so any help on how to set this up in the Code Block would be greatly appreciated.