Created
January 4, 2016 14:55
-
-
Save tjmichael81/aec863a9f48aca201ac3 to your computer and use it in GitHub Desktop.
Use arcpy.CalculateField_management to concatenate two fields with a separator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
fc = '<path to fc or table>' | |
field_CommonName = 'Field_CommonName' | |
field_BotanicalName = 'Field_BotanicalName' | |
# Takeaway - enclose the entire expression in quotes, don't do this: | |
# commonNameExpression = !Field_Name! + ' - ' + !Current_Crop_2013! | |
commonNameExpression = "!Field_Name! + ' - ' + !Current_Crop_2013!" | |
botanicalNameExpression = "!Field_Name! + ' - ' + !Current_Crop_2013_Botanical!" | |
arcpy.CalculateField_management(fc, field_CommonName, commonNameExpression, 'PYTHON_9.3') | |
arcpy.CalculateField_management(fc, field_BotanicalName, botanicalNameExpression, 'PYTHON_9.3') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment