Calulate Field in model Builder Script Not working

784
7
11-30-2011 04:03 PM
WilliamIde
New Contributor II
I am have a created a model in Model builder to Calculate a date field from an existing field to a new field that I just created. The model works fine.  However now I would like to expand this functionality by growing the script.  Well right at the start I tried to run it un-modified from model builder.  No go.
I am running Arc 10.  All it includes is:
   

import arcpy

The error is 000732

I notice that the imports are different from 9.3 to 10.  Any clue as to why this doesn't work?  Is Calculate field one of the tools that don't work in python?  I there a work around?
Urban
Tags (2)
0 Kudos
7 Replies
MathewCoyle
Frequent Contributor
I highly doubt you are getting a 732 error from simply importing arcpy, can you try posting the entire code in
code tags?
0 Kudos
WilliamIde
New Contributor II
OK Here is the Script.

#-______
#
# Mag_fieldcalc5.py
#
# Description
#---------

#import Arcpy
import arcpy

#local Variables
mag_subset__2_ = "fdmag_subset"

# Process: Calculate Field

arcpy.CalculateField_management(mag_subset___,"RM_DATE_MODIFIED","[REPORT_DATE]", "PYTHON_9.3", "")


Here is the Error listing:

Trackeback ( most recent call last)
File "D:\Projects\mag_fieldcalc5.py", Line 16 in <module>
arcpy.CalculateField_management(mag_subset___,"RM_DATE_MODIFIED","[REPORT_DATE]", "PYTHON_9.3", "")
File "c:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\management.py", line 2727, in CalculateField
      raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Imput Table: Dataset mag_subset does not exist or is not supported
Failed to execute (CalculateField)


Again this is how it was exported out of the Model Builder.

Usually I break things after I fool with them.  But, this is broken right out of the box.
0 Kudos
MathewCoyle
Frequent Contributor
mag_subset__2_ != mag_subset___

That's most likely your main problem.

Exporting models to python rarely works as intended raw, it gives you a good framework on which to build.
0 Kudos
WilliamIde
New Contributor II
I had to type the whole thing because the system I am working on is not on a network.  The tokens are the same mag_subset__2_
0 Kudos
MathewCoyle
Frequent Contributor
It's hard to narrow down your error without the specific code you are using and error messages you are getting.

If you are referencing an existing field, it should look like
arcpy.CalculateField_management(mag_subset__2_,"RM_DATE_MODIFIED","!REPORT_DATE!","PYTHON_9.3","#")
0 Kudos
WilliamIde
New Contributor II
Mine is almost exactly that except for the # at the end.  I posted  all of code and  error messages that I have.
0 Kudos
WilliamIde
New Contributor II
Turns out I had multiple nit niods.  First.  env=\myproj\mygdb.gdb  Second I was using a personal gdb not a file gdb.  The locks and permissions are not quite the same.  Other than that it works a charm.
0 Kudos