I'm using ArcGIS 10 and new at python scripting. I have a string field that I need to calculate by multiplying two other string fields. I can do it in python using two arbitrary values...
CINPT1 = "1.00"
CNETVAL = "8500"
print int(float(CINPT1) * int(CNETVAL))
but...I need this as an arcpy fieldcalculation. What I have now is below. I'm basically trying to what is above: the CNETVAL field should equal CINPT1 * CUNITV
import arcpy, sys, string, os
MAPCHAR = "MAPCHAR"
CINPT1 = "CINPT1"
CNETVAL = "CNETVAL"
CUNITV = "CUNITV"
expression = "multiStringFunc(!CNETVAL!)"
codeblock = """def multiStringFunc(netvalue):
value1 = float(CINPT1)
unitvalue = int(CUNITV)
netvalue = int(value1 * unitvalue)
return netvalue"""
# Process: CUNITV = CINPT1 * CUNITV
arcpy.CalculateField_management(MAPCHAR, CINPT1, expression, "Python", codeblock)
What i get in return is "global name 'CINPT1' is not defined". I am pretty new at using python, so i don't know if I'm just using the value wrong within the codeblock or I'm just totally off. Anything you can contribute would be appreciated. Thanks!