Calculate Field Tool Does not Complete - Help

3826
33
Jump to solution
04-10-2013 07:42 AM
ModernElectric
Frequent Contributor
I need help really bad. I have been looking through all of the Forum posts and and Help sections to try to figure out what is wrong with no luck. Here is what I am doing:
    I have a File Geodatabase (ArcMap 10.0) with a Feature Class (Service Location) which is the physical location of our electric meters. I have multiple fields that I need to update on a nightly basis. This data comes from our CIS system which holds account, customer and meter attribute information. I have a script to runs automatically every night that pulls an Oracle VW through an ODBC connection and brings it into my File Geodatabase as a Geodatabase Table. What I have to do is to update a specific field (Account Number) in the Feature Class with the same field in the table (ACCOUNTNUM)... Just an example. What I want to be able to do is to also have this script run automatically at night. I have around 9500 records in the feature class with about 15 different fields to do this to. The problem I am having is it takes up to 20 to 25 minutes for each field to update so at times - the script can take 8 to 9 hours to complete. From what I understand - this should take only a few minutes.... So what I am doing is not working.
I decided to go back to the "Drawing Board" to see if there is something I am missing with writing the code..... I decided to work with (1) field right now to see if I can make it work and get the update time down before I rewrite the rest of the code.

This is what I currently have and it does not seem to be working:

## Set the necessary product code import logging  # Import arcpy module import arcpy from arcpy import env   # if run in ArcGIS Desktop, show messages, also print to log def log(method, msg):     print msg     method(msg)  logging.basicConfig(         level=logging.INFO,         format='%(asctime)s %(levelname)-s %(message)s',         datefmt='%a, %d %b %Y %H:%M:%S',         filename='Test_Update.log',         filemode='w'         )  log(logging.info, "Updating Service Locations Feature Class Begins")  # Set environment settings env.workspace = "C:\\MEWCo GIS System\\Electric System\\MEWCo_Electric_Model-LOCAL.gdb"  # Set Local variables: inFeatures = "SERVICE_LOCATION"                         # Service Location Feature Class layerName = "SERVICE_LOCATION_LAYER"                    # Service Location Feature Layer fieldName1 = "SERVICE_ADDRESS" expression1 = "CIS_Account_Data.SERVICE_ADDRESS" joinField = "POLE_NUMBER" joinField2 = "MAPNO" joinTable = "CIS_Account_Data"  # Create a Feature Layer from Service_Location Feature Class log(logging.info, "Create Feature Layer for Service Location Feature Class") arcpy.MakeFeatureLayer_management(inFeatures, layerName)  # Join the feature layer to a table log(logging.info, "Join Table to Feature Layer Service Location") arcpy.AddJoin_management(layerName, joinField, joinTable, joinField2)      # Process: Calculate Field (Member Number) log(logging.info, "Update Member Number Field") arcpy.CalculateField_management(layerName, "SERVICE_LOCATION.MEMBER_NUMBER", '!MEMBERNO!', "PYTHON")  log(logging.info, "Complete")


I am not sure what is slowing this down. Am I looking at this process the wrong way?? Are there different tools that can be used to complete this mission??

Thank you for your help
Tags (2)
0 Kudos
33 Replies
by Anonymous User
Not applicable
One good website is from Penn State, there is an free online GIS Programming class:

https://www.e-education.psu.edu/geog485/

Python.org is also a great resource for standard library stuff (dicitionaries, lists, etc)

The Penn State one is the best I have seen online.  Also, if you're interested, I taught 2 Python Workshops at a GIS Conference a few weeks ago so I have lots of learning material and practice exercises I wrote for that.  Send me a private message with your email info if you want that material (beginner and advanced session).  I cover a few exercises on dictionaries and writing your own functions in the advanced stuff.  I am no expert in Python, but I think included some stuff that is good for a beginner.

As for your other question, you can just have a new script that imports the MemoryTableTools and have a bunch of tables you want to run it on and set it up like this:

import arcpy, os, sys
from MemoryTableTools import *

# IF all feature classes are in the same gdb
arcpy.env.workspace = r'C:\MEWCo GIS System\Electric System\MEWCo_Electric_Model-LOCAL.gdb'

# set up a list of tables
table1 = 'CIS_Service_Meters'
table2 = 'anothertable'
table3 = r'FeatureDataset\Another_FC'
table4 = 'yetAnotherTable'
# etc.....


# run this as many times as you need to 
AttributeUpdate(...........)
AttributeUpdate(...........)
AttributeUpdate(...........)

0 Kudos
MichaelVolz
Esteemed Contributor
Caleb:

I would be interested in the advanced material you have.

How do I go about sending you a private message?

Thank you.
0 Kudos
by Anonymous User
Not applicable

How do I go about sending you a private message?


Hi Michael,

I just sent you a private message, but you can just click on my username (Caleb1987) and choose Private Message.
0 Kudos
MichaelVolz
Esteemed Contributor
Chris:

The script that I am currently using in production that uses Calculate field with an index is being replaced by a View as the data is being migrated to SDE.  This simplifies the entire process where no python script is required.

Do you have the means to get your data into an SDE database and create views?  My organization has a Database Administrator which is allowing us to more into this simpler environment where no python script is required.
0 Kudos