Looking up the 000010 Error I don't see anything in connection to "The table already exists". I looked over everything in the one help doc I found and nothing therein seems to be relevant. https://pro.arcgis.com/en/pro-app/2.8/tool-reference/tool-errors-and-warnings/001001-010000/tool-err...
I've been testing this script for a week now and I haven't been hung up on this error. I set OverwriteOutput to True. I'm not using a shapefile anywhere. I'm saving to a GDB. If anyone has any pointers I'd appreciate it!
import arcpy, csv
from arcgis.gis import GIS
import os
portal = r"https://willcountygis.maps.arcgis.com/" #<--Can also reference a local portal
user = 'username'
password = 'password'
arcpy.SignInToPortal(portal,user,password) #<--use this if script is run outside Pro
gis = GIS('https://willcountygis.maps.arcgis.com', 'username', 'password')
arcpy.env.overwriteOutput = True
'''
1. Grab Waste Recycling Contractor Reporting Form (results from Survey123) feature service and export to table, then save in Default.gdb
'''
layer_name = "Waste Recycling Contractor Reporting Form"
defaultDB = r'\\pathto\Projects\Will County Green\WasteRecyclingReport\Default.gdb'
#Create feature class from input feature service.
wasteRecyclingReportFS = arcpy.MakeFeatureLayer_management("https://services.arcgis.com/fGsbyIOAuxHnF97m/arcgis/rest/services/service_e42e606d08284c32bbefd94b6f18764a/FeatureServer/0",
layer_name)
print(f'Survey123 results being exported to table')
#export to table
arcpy.conversion.TableToTable(wasteRecyclingReportFS, defaultDB, 'wasteRecyclingReport')
'''
2. geocode the addresses with the ArcGIS World Geocoding Service
'''
#ArcGIS World Geocoding Service URL
locator = "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/ArcGIS World Geocoding Service"
#Locator parameters
fieldMap = ("'Address or Place' addy VISIBLE NONE;Address2 <None> VISIBLE NONE;Address3 <None> VISIBLE NONE;Neighborhood <None> VISIBLE NONE;City city VISIBLE NONE;County <None> VISIBLE NONE;State state VISIBLE NONE;ZIP zip VISIBLE NONE;ZIP4 <None> VISIBLE NONE;Country <None> VISIBLE NONE")
gcName = "wasteRecyclingReport_geocode"
#newly created table of survey data
in_table = os.path.join(defaultDB, "wasteRecyclingReport")
geocodeResult = os.path.join(defaultDB, gcName)
print(f'Geocoding table')
# perform geocode
arcpy.geocoding.GeocodeAddresses(in_table,locator,fieldMap, geocodeResult, "STATIC", None, "ROUTING_LOCATION", None, "ALL")
Print statements and error:
Survey123 results being exported to table
Geocoding table
---------------------------------------------------------------------------
ExecuteError Traceback (most recent call last)
In [1]:
Line 44: arcpy.geocoding.GeocodeAddresses(in_table,locator,fieldMap, geocodeResult, "STATIC", None, "ROUTING_LOCATION", None, "ALL")
File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geocoding.py, in GeocodeAddresses:
Line 519: raise e
File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geocoding.py, in GeocodeAddresses:
Line 516: retval = convertArcObjectToPythonObject(gp.GeocodeAddresses_geocoding(*gp_fixargs((in_table, address_locator, in_address_fields, out_feature_class, out_relationship_type, country, location_type, category, output_fields), True)))
File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py, in <lambda>:
Line 512: return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 000010: Geocode addresses failed.
The table already exists. [wasteRecyclingReport_geocode]
Failed to execute (GeocodeAddresses).
---------------------------------------------------------------------------
EDIT: Just an observation, arcpy.conversion.TableToTable() doesn't have a problem with overwriting as you can see from the print statement. So, why is the geocoded table not overwriting?
Solved! Go to Solution.
I don't have an example, but in my experience, this issue can stem from how the path is being passed.
Try to hard code the in_table and geocodeResult variables as a string (rather than path). Alternatively, try passing them as a string object rather than the path object using f-strings.
#newly created table of survey data
in_table = os.path.join(defaultDB, "wasteRecyclingReport")
geocodeResult = os.path.join(defaultDB, gcName)
print(f'Geocoding table')
# perform geocode
arcpy.geocoding.GeocodeAddresses(f'{in_table}',locator,fieldMap, f'{geocodeResult}', "STATIC", None, "ROUTING_LOCATION", None, "ALL")
I don't have an example, but in my experience, this issue can stem from how the path is being passed.
Try to hard code the in_table and geocodeResult variables as a string (rather than path). Alternatively, try passing them as a string object rather than the path object using f-strings.
#newly created table of survey data
in_table = os.path.join(defaultDB, "wasteRecyclingReport")
geocodeResult = os.path.join(defaultDB, gcName)
print(f'Geocoding table')
# perform geocode
arcpy.geocoding.GeocodeAddresses(f'{in_table}',locator,fieldMap, f'{geocodeResult}', "STATIC", None, "ROUTING_LOCATION", None, "ALL")
I thought it worked, but I think it only worked because I first removed the table from the FGDB before I ran the script. Once I ran it with that table existing in the FGDB I got the same error.
The way I finally got it to work was to first delete the table before I ran the geocode function.
tables = arcpy.ListTables()
for table in tables:
arcpy.Delete_management(table)[0]
@JohnMiller7
Very good to know, thanks. I put the full path for the in_table variable and it ran successfully.
in_table = r'\\pathto\Projects\Will County Green\WasteRecyclingReport\Default.gdb\wasteRecyclingReport'