AnsweredAssumed Answered

Python Runtime Error

Question asked by pforrest on Jul 24, 2020
Latest reply on Jul 24, 2020 by bixb0012

Greetings,

 

I'm trying to run my python script (from which I've just exported a ModelBuilder model) and I keep getting this Runtime error.  Here is the script:

import arcpy

def Model(): # Model

# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = True

restaurant_scores_csv = "P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv"
ReastaurantInspections_gdb = "C:\\arcgisserver\\arcgisresources\\Code\\ReastaurantInspections.gdb"
CompositeSubStreet_loc = "S:\\Police\\GIS\\AddressLocators\\CompositeSubStreet.loc"

# Process: Table To Table (Table To Table)
Scores = arcpy.TableToTable_conversion(in_rows=restaurant_scores_csv, out_path=ReastaurantInspections_gdb, out_name="Scores", where_clause="", field_mapping="BUSINESS_NO \"BUSINESS_NO\" true true false 4 Long 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,BUSINESS_NO,-1,-1;SITE_APN \"SITE_APN\" true true false 8000 Text 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,SITE_APN,0,8000;COMPANY \"COMPANY\" true true false 8000 Text 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,COMPANY,0,8000;LOC_ADDRESS1 \"LOC_ADDRESS1\" true true false 8000 Text 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,LOC_ADDRESS1,0,8000;INSPECTIONTYPE \"INSPECTIONTYPE\" true true false 8000 Text 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,INSPECTIONTYPE,0,8000;INSPECTOR \"INSPECTOR\" true true false 8000 Text 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,INSPECTOR,0,8000;BUS_LIC_NO \"BUS_LIC_NO\" true true false 8000 Text 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,BUS_LIC_NO,0,8000;STATUS \"STATUS\" true true false 8000 Text 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,STATUS,0,8000;LATEST_REVIEW_DATE \"LATEST_REVIEW_DATE\" true true false 8 Date 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,LATEST_REVIEW_DATE,-1,-1;LATEST_SCORE \"LATEST_SCORE\" true true false 8000 Text 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,LATEST_SCORE,0,8000;RECORDID \"RECORDID\" true true false 8000 Text 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,RECORDID,0,8000;PREVIOUS_REVIEW_DATE \"PREVIOUS_REVIEW_DATE\" true true false 8000 Text 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,PREVIOUS_REVIEW_DATE,0,8000;PREVIOUS_SCORE \"PREVIOUS_SCORE\" true true false 8000 Text 0 0,First,#,P:\\GIS\\Brad Simpson\\Python\\restaurant_scores.csv,PREVIOUS_SCORE,0,8000", config_keyword="")[0]

# Process: Geocode Addresses (Geocode Addresses)
Scores_Geocoded = "C:\\arcgisserver\\arcgisresources\\Code\\ReastaurantInspections.gdb\\Scores_Geocoded"
arcpy.GeocodeAddresses_geocoding(in_table=Scores, address_locator=CompositeSubStreet_loc, in_address_fields="'Single Line Input' LOC_ADDRESS1 VISIBLE NONE", out_feature_class=Scores_Geocoded, out_relationship_type="STATIC", country=[], location_type="", category=[])

# Process: Add Field (Add Field)
Scores_Geocoded_2_ = arcpy.AddField_management(in_table=Scores_Geocoded, field_name="establishmentname", field_type="TEXT", field_precision=None, field_scale=None, field_length=200, field_alias="Establishment Name", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="")[0]

# Process: Add Field (2) (Add Field)
Scores_Geocoded_3_ = arcpy.AddField_management(in_table=Scores_Geocoded_2_, field_name="address", field_type="TEXT", field_precision=None, field_scale=None, field_length=200, field_alias="Full Address", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="")[0]

# Process: Add Field (3) (Add Field)
Scores_Geocoded_4_ = arcpy.AddField_management(in_table=Scores_Geocoded_3_, field_name="identifier", field_type="TEXT", field_precision=None, field_scale=None, field_length=50, field_alias="Identifier", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="")[0]

# Process: Add Field (4) (Add Field)
Scores_Geocoded_5_ = arcpy.AddField_management(in_table=Scores_Geocoded_4_, field_name="permnum", field_type="TEXT", field_precision=None, field_scale=None, field_length=50, field_alias="Permit Number", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="")[0]

# Process: Add Field (5) (Add Field)
Scores_Geocoded_6_ = arcpy.AddField_management(in_table=Scores_Geocoded_5_, field_name="inspdate", field_type="DATE", field_precision=None, field_scale=None, field_length=50, field_alias="Inspection Date", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="")[0]

# Process: Add Field (6) (Add Field)
Scores_Geocoded_11_ = arcpy.AddField_management(in_table=Scores_Geocoded_6_, field_name="latestscore", field_type="TEXT", field_precision=None, field_scale=None, field_length=100, field_alias="Latest Score", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="")[0]

# Process: Add Field (7) (Add Field)
Scores_Geocoded_8_ = arcpy.AddField_management(in_table=Scores_Geocoded_11_, field_name="PreviousTempDate", field_type="TEXT", field_precision=None, field_scale=None, field_length=50, field_alias="Previous Inspection Date", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="")[0]

# Process: Add Field (8) (Add Field)
Scores_Geocoded_7_ = arcpy.AddField_management(in_table=Scores_Geocoded_8_, field_name="previnspscore", field_type="TEXT", field_precision=None, field_scale=None, field_length=50, field_alias="Previous Inspection Score", field_is_nullable="NULLABLE", field_is_required="NON_REQUIRED", field_domain="")[0]

# Process: Calculate Field (Calculate Field)
Scores_Geocoded_9_ = arcpy.CalculateField_management(in_table=Scores_Geocoded_7_, field="establishmentname", expression="!USER_COMPANY!", expression_type="PYTHON3", code_block="", field_type="TEXT")[0]

# Process: Calculate Field (2) (Calculate Field)
Scores_Geocoded_18_ = arcpy.CalculateField_management(in_table=Scores_Geocoded_9_, field="address", expression="!USER_LOC_ADDRESS1!", expression_type="PYTHON3", code_block="", field_type="TEXT")[0]

# Process: Calculate Field (3) (Calculate Field)
Scores_Geocoded_12_ = arcpy.CalculateField_management(in_table=Scores_Geocoded_18_, field="identifier", expression="!USER_INSPECTOR!", expression_type="PYTHON3", code_block="", field_type="TEXT")[0]

# Process: Calculate Field (4) (Calculate Field)
Scores_Geocoded_10_ = arcpy.CalculateField_management(in_table=Scores_Geocoded_12_, field="inspdate", expression="!USER_LATEST_REVIEW_DATE!", expression_type="PYTHON3", code_block="", field_type="TEXT")[0]

# Process: Calculate Field (5) (Calculate Field)
Scores_Geocoded_13_ = arcpy.CalculateField_management(in_table=Scores_Geocoded_10_, field="latestscore", expression="!USER_LATEST_SCORE!", expression_type="PYTHON3", code_block="", field_type="TEXT")[0]

# Process: Calculate Field (6) (Calculate Field)
Scores_Geocoded_14_ = arcpy.CalculateField_management(in_table=Scores_Geocoded_13_, field="PreviousTempDate", expression="!USER_PREVIOUS_REVIEW_DATE!", expression_type="PYTHON3", code_block="", field_type="TEXT")[0]

# Process: Calculate Field (7) (Calculate Field)
Scores_Geocoded_15_ = arcpy.CalculateField_management(in_table=Scores_Geocoded_14_, field="permnum", expression="!USER_BUS_LIC_NO!", expression_type="PYTHON3", code_block="", field_type="TEXT")[0]

# Process: Calculate Field (8) (Calculate Field)
Scores_Geocoded_16_ = arcpy.CalculateField_management(in_table=Scores_Geocoded_15_, field="previnspscore", expression="!USER_PREVIOUS_SCORE!", expression_type="PYTHON3", code_block="", field_type="TEXT")[0]

# Process: Delete Field (Delete Field)
Scores_Geocoded_17_ = arcpy.DeleteField_management(in_table=Scores_Geocoded_16_, drop_field=["Loc_name", "Status", "Score", "Match_type", "Match_addr", "User_fld", "Addr_type", "Side", "IN_SingleLine", "USER_BUSINESS_NO", "USER_SITE_APN", "USER_COMPANY", "USER_LOC_ADDRESS1", "USER_INSPECTIONTYPE", "USER_INSPECTOR", "USER_BUS_LIC_NO", "USER_STATUS", "USER_LATEST_SCORE", "USER_LATEST_REVIEW_DATE", "USER_RECORDID", "USER_PREVIOUS_REVIEW_DATE", "USER_PREVIOUS_SCORE"])[0]

if __name__ == '__main__':
# Global Environment settings
with arcpy.EnvManager(scratchWorkspace=r"C:\Users\pforrest\Documents\ArcGIS\Projects\Restaurant Inspections\Restaurant Inspections.gdb", workspace=r"C:\Users\pforrest\Documents\ArcGIS\Projects\Restaurant Inspections\Restaurant Inspections.gdb"):
Model()

 

 

The error I get is:

RuntimeError: Object: Error in executing tool

 

No other messages that I can work off of.  Any help would be much appreciated!

Outcomes