Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Calculate Field Tool Does not Complete - Help

$
0
0
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:

Code:

## 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

Viewing all articles
Browse latest Browse all 2485

Trending Articles