mvolz47;287670 wrote:
When you are posting your reply go to the Code wrap menu and select # (It is in the 2nd row to the right above the posting window). Put CODE (with brackets) at the beginning of your code and /CODE (with brackets) at the end of your code as shown in my below sample that does not do anything but provide a visual sample.
#
# Set the necessary product code
import logging
# Import arcpy module
import arcpy
# 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='ServiceLocationsAttributes_Updates.log',
filemode='w'
)
log(logging.info, "Updating Service Locations Feature Class Begins")
# Local variables:
SERVICE_LOCATION = "C:\\MEWCo GIS System\\Electric System\\MEWCo_Electric_Model-LOCAL.gdb\\Electric\\SERVICE_LOCATION"
CIS_Account_Data = "C:\\MEWCo GIS System\\Electric System\\MEWCo_Electric_Model-LOCAL.gdb\\CIS_Account_Data"
CIS_Service_Meters = "C:\\MEWCo GIS System\\Electric System\\MEWCo_Electric_Model-LOCAL.gdb\\CIS_Service_Meters"
SERVICE_LOCATION_FL = "SERVICE_LOCATION_FL"
SERVICE_LOCATION_FL__2_ = "SERVICE_LOCATION_FL"
SERVICE_LOCATION_FL__24_ = "SERVICE_LOCATION_FL"
# Process: Make Feature Layer of Service Location FC
log(logging.info, "Create Feature Layer for Service Location Feature Class")
arcpy.MakeFeatureLayer_management(SERVICE_LOCATION, SERVICE_LOCATION_FL, "", "", "SUBTYPE SUBTYPE VISIBLE NONE;PHASE PHASE VISIBLE NONE;OH_UG OH_UG VISIBLE NONE;FLOW FLOW VISIBLE NONE;PROTECTION_DEVICE PROTECTION_DEVICE VISIBLE NONE;CIS_SERVICE_ID CIS_SERVICE_ID VISIBLE NONE;TRANSFORMER_BANK_ID TRANSFORMER_BANK_ID VISIBLE NONE;POLE_NUMBER POLE_NUMBER VISIBLE NONE;LINE_AND_POLE LINE_AND_POLE VISIBLE NONE;LOCATION_TAG LOCATION_TAG VISIBLE NONE;CIRCUIT_ID CIRCUIT_ID VISIBLE NONE;CIRCUIT_SOURCE CIRCUIT_SOURCE VISIBLE NONE;ASSEMBLY_CODE ASSEMBLY_CODE VISIBLE NONE;DESIGN_STATE DESIGN_STATE VISIBLE NONE;COMMENTS COMMENTS VISIBLE NONE;LABEL_TEXT LABEL_TEXT VISIBLE NONE;LOT_NUMBER LOT_NUMBER VISIBLE NONE;EASEMENT EASEMENT VISIBLE NONE;ATS_DIRTY ATS_DIRTY VISIBLE NONE;DTS_CREATED DTS_CREATED VISIBLE NONE;DTS_CHANGED DTS_CHANGED VISIBLE NONE;CHANGED_BY CHANGED_BY VISIBLE NONE;ATS_GUID ATS_GUID VISIBLE NONE;LOCATION_OID LOCATION_OID VISIBLE NONE;SYMBOL_ROTATION SYMBOL_ROTATION VISIBLE NONE;ANCILLARYROLE ANCILLARYROLE VISIBLE NONE;ENABLED ENABLED VISIBLE NONE;OLD_LOCATION OLD_LOCATION VISIBLE NONE;TRANSFORMER_MAPNO TRANSFORMER_MAPNO VISIBLE NONE;TRUCK_NUMBER TRUCK_NUMBER VISIBLE NONE;SHAPE SHAPE VISIBLE NONE;OBJECTID OBJECTID VISIBLE NONE;METER_TYPE_ID METER_TYPE_ID VISIBLE NONE;METER_PACK_OID METER_PACK_OID VISIBLE NONE;METER_SOCKET METER_SOCKET VISIBLE NONE;SERVICE_ADDRESS SERVICE_ADDRESS VISIBLE NONE;LOC_TYPE LOC_TYPE VISIBLE NONE;SERVICE_TYPE SERVICE_TYPE VISIBLE NONE;MEMBER_NUMBER MEMBER_NUMBER VISIBLE NONE;CUSTOMER_NAME CUSTOMER_NAME VISIBLE NONE;MAIL_ADDRESS MAIL_ADDRESS VISIBLE NONE;MAIL_CITY MAIL_CITY VISIBLE NONE;MAIL_STATE MAIL_STATE VISIBLE NONE;MAIL_ZIP MAIL_ZIP VISIBLE NONE;ACCOUNT_NUMBER ACCOUNT_NUMBER VISIBLE NONE;TWACS_NUMBER TWACS_NUMBER VISIBLE NONE;METER_TYPE METER_TYPE VISIBLE NONE;METER_BOOK METER_BOOK VISIBLE NONE;BILLING_CYCLE BILLING_CYCLE VISIBLE NONE;PHONE PHONE VISIBLE NONE;PHONE_TYPE PHONE_TYPE VISIBLE NONE;ACCOUNT_STATUS ACCOUNT_STATUS VISIBLE NONE;RATE_CODE RATE_CODE VISIBLE NONE;MULTIPLIER MULTIPLIER VISIBLE NONE;READ_DATE READ_DATE VISIBLE NONE;BILLED_DATE BILLED_DATE VISIBLE NONE;DISCONNECT_DATE DISCONNECT_DATE VISIBLE NONE;CIS_EXPORT_DATE CIS_EXPORT_DATE VISIBLE NONE;DIAL_STYLE DIAL_STYLE VISIBLE NONE;KSUBH KSUBH VISIBLE NONE;FORM FORM VISIBLE NONE;METER_AMPS METER_AMPS VISIBLE NONE;METER_WIRES METER_WIRES VISIBLE NONE;METER_VOLTS METER_VOLTS VISIBLE NONE;METER_CLASS METER_CLASS VISIBLE NONE;METER_TYPE_DESC METER_TYPE_DESC VISIBLE NONE;MANUFACTURER MANUFACTURER VISIBLE NONE;SERVICE_ADD_NOTE SERVICE_ADD_NOTE VISIBLE NONE;AMPS AMPS VISIBLE NONE;SOCKET_CONDITION SOCKET_CONDITION VISIBLE NONE;POINT_X POINT_X VISIBLE NONE;POINT_Y POINT_Y VISIBLE NONE;MEWCo_MAP_GRID MEWCo_MAP_GRID VISIBLE NONE")
# Process: Add Join (CIS Account Data Table)
log(logging.info, "Add CIS_Account_Data Table to Feature Layer")
arcpy.AddJoin_management(SERVICE_LOCATION_FL, "POLE_NUMBER", CIS_Account_Data, "MAPNO", "KEEP_ALL")
# Process: Calculate Field (Member Number)
log(logging.info, "Update Member Number Field")
arcpy.CalculateField_management(SERVICE_LOCATION_FL__2_, "SERVICE_LOCATION.MEMBER_NUMBER", "[CIS_Account_Data.MEMBERNO]", "VB", "")
# Process: Calculate Field (Customer Name)
log(logging.info, "Update Customer Name Field")
arcpy.CalculateField_management(SERVICE_LOCATION_FL__2_, "SERVICE_LOCATION.CUSTOMER_NAME", "[CIS_Account_Data.CUSTNAME]", "VB", "")
# Process: Calculate Field (Mailing Address)
log(logging.info, "Update Mail Address Field")
arcpy.CalculateField_management(SERVICE_LOCATION_FL__2_, "SERVICE_LOCATION.MAIL_ADDRESS", "[CIS_Account_Data.MAIL_ADDRESS]", "VB", "")
# Process: Calculate Field (Mail City)
log(logging.info, "Update Mail City Field")
arcpy.CalculateField_management(SERVICE_LOCATION_FL__2_, "SERVICE_LOCATION.MAIL_CITY", "[CIS_Account_Data.MAIL_CITY]", "VB", "")
# Process: Calculate Field (Mail State)
log(logging.info, "Update Mail State Field")
arcpy.CalculateField_management(SERVICE_LOCATION_FL__2_, "SERVICE_LOCATION.MAIL_STATE", "[CIS_Account_Data.MAIL_STATE]", "VB", "")
# Process: Calculate Field (Mail Zip)
log(logging.info, "Update Mail Zip Field")
arcpy.CalculateField_management(SERVICE_LOCATION_FL__2_, "SERVICE_LOCATION.MAIL_ZIP", "[CIS_Account_Data.ZIP]", "VB", "")
Here is a clip of the code