AnsweredAssumed Answered

arcpy GeocodeAddresses does not map fields correctly. Is this a bug?

Question asked by tjohnsto on Apr 22, 2015

I wrote a testcase which demonstrates a problem where the arcpy.geocoding.GeocodeAddresses function is not mapping fields correctly.  This function only appears to work when the field names are mapped with exactly the same names.  I created this python script which reads in 2 CSV files which are exactly the same except one of the CSV files named the address column as ADDRESSX which causes the mapping to fail.  If you run this script (after entering your ArcGIS Online userId and Password) you will notice that you will have 2 Resulting feature classes with different results.  This is because the ADDRESSX column was skipped by GeocodeAddresses because it was mapped incorrectly.  I believe this is a bug.  I am using ArcGIS v10.2.2.3552.  Attached is my python script and the 2 CSV files.


# Note: This Geocoding Testcase will consume credits on ArcGIS Online.

import arcpy

import sys

import os


cwd = sys.path[0]


# Read CVS files

# These files are the same except the customersx.csv ADDRESS column is named ADDRESSX

input_table = os.path.join(cwd, "customers.csv")

input_tablex = os.path.join(cwd, "customersx.csv")


# Create a file geodatabase to store the output feature class

output_gdb_name = "Outputs.gdb"

output_gdb = os.path.join(cwd, output_gdb_name)

if not os.path.exists(output_gdb):, output_gdb_name)


# Store results in 2 separate Feature Classes

output_feature_class = os.path.join(output_gdb,"CustomerLocations")

output_feature_classx = os.path.join(output_gdb,"CustomerLocationsx")


# Create the ArcGIS Server connection file

server_url = ""

conn_file_name = "arcgis_online_batch_geocoding.ags"

conn_file = os.path.join(cwd, conn_file_name)

username = "[My Enterprise ArcGIS Online ID]"

password = "[My Password]"

arcpy.mapping.CreateGISServerConnectionFile("USE_GIS_SERVICES", cwd, conn_file_name, server_url,

                                            "ARCGIS_SERVER", username=username, password=password)


address_locator = os.path.join(conn_file, "World.GeocodeServer")


# Geocode both CSV files

arcpy.geocoding.GeocodeAddresses(input_table, address_locator, "Address Address;City City;Region State;Postal Zip", output_feature_class)

arcpy.geocoding.GeocodeAddresses(input_tablex, address_locator, "Address Addressx;City City;Region State;Postal Zip", output_feature_classx)


print arcpy.GetMessages()