laptop and a wrench

Bug

CalculateField, is failing when using joined fields in the expression with PYTHON calculation types.

Last Published: August 25, 2014 No Product Found
Bug ID Number NIM009969
SubmittedJune 28, 2007
Last ModifiedJune 5, 2024
Applies toNo Product Found
Version found9.2
Version Fixed9.3
StatusFixed

Description

Calculate Field is failing when using join fields in the expression with PYTHON calculation types.

Example Code:

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()
gp.overwriteoutput = 1

# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")

# Local variables...
population = "D:\\testdata\\Geodatabase.mdb\\population"
cities = "D:\\testdata\\Geodatabase.mdb\\cities"
Table_Name = "population_View"
population_View = "population_View"
population_View__2_ = "population_View"
population_View__3_ = "population_View"

# Process: Make Table View...
gp.MakeTableView_management(population, Table_Name, "", "", "CITY CITY VISIBLE;POP2007 POP2007 VISIBLE;Acres Acres VISIBLE")

# Process: Add Field...
gp.AddField_management(Table_Name, "Acres", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")

# Process: Add Join...
gp.AddJoin_management(population_View, "CITY", cities, "MB_NAME", "KEEP_ALL")

# Process: Calculate Field...
gp.CalculateField_management(population_View__2_, "population.Acres", "float(!SHAPE.AREA!/43560)", "PYTHON")

Cause

Python is interpreting the table name as a field name, and the field name as a parameter.

Workaround

Instead of using PYTHON syntax in the expression parameter, use VB (Visual Basic) syntax.

Example:

# Process: Calculate Field...
gp.CalculateField_management(population_View__2_, "population.Acres", "[SHAPE.AREA]/43560", "VB")

    Steps to Reproduce

    Bug ID: NIM009969

    Software:

    • No Product Found

    Get notified when the status of a bug changes

    Download the Esri Support App

    Related Information

    Discover more on this topic

    Get help from ArcGIS experts

    Contact technical support

    Download the Esri Support App

    Go to download options