Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I have never posted here before. I have used the site a lot for help so many thanks to all the great contributors. So, I have used ArcGIS online to perform batch geocoding (18,000) records and it works great. Extremely fast and accurate. It does however chew up a LOT of credits. This is something I cannot sustain in the long term. To avoid that credit drain I would like to split my table out by the "State" Column and geocode individual states and then merge back together. The free online geocoder can handle smaller datasets and by breaking down by state I think I could acheive this. So far I have:

import arcpy
fc ="C:\GISProjects\ALLMembers\LEE_AllMembers.gdb\LeeMembers_Sort"
field = "State"
myList=set([row.getValue(field) for row in arcpy.SearchCursor(fc)])
for row in myList:
    print myList

This works and returns the set of values. I guess I"m wondering now how to take those values and arcpy.TabletoTable_Conversion? From there I could geocode each separate table and merge the results.

any help is much appreciated!

share|improve this question
What is your original input and what is your expected output? – gm70560 May 17 '13 at 14:14
TableToTable_Conversion takes a where clause, so you could just query a unique list of states, and loop over this in python calling TableToTable_Conversion with a where clause "State = '" + current_state + "'" – Matthew Plourde May 17 '13 at 14:33
up vote 1 down vote accepted

I will assume you have many records per state that need to be geocoded, in which case you do not want to do this one record at a time, but in batches.

you can tweak your code a little to do this.

import arcpy
states = []
fc ="C:\GISProjects\ALLMembers\LEE_AllMembers.gdb\LeeMembers_Sort"
field = "State"
myList=set([row.getValue(field) for row in arcpy.SearchCursor(fc)])
for row in myList:
    if myList not in states:
        states.append(myList) # this will give you a list of the results of your search cursor

for state in states:
    arcpy.TableToTabel_conversion(input_table, output_path, output_name,""" "State" = '""" +state +"""'""") 

You will need to define the input/output parameters (input_table, output_path), but this should give you an output file for each of the states in your input data

share|improve this answer
You want to reduce the list of states to unique states with states = list(set(states)). Otherwise, this creates a table for every instance of a state. – Matthew Plourde May 17 '13 at 18:15
@Hotpepper Thanks so much for the help! I heeded all of your advice but am having one hiccup along the way. I am getting an error message TypeError: cannot concatenate 'str' and 'int' objects "output_name='output_'+counter – Emerson Chew May 20 '13 at 16:56
ah, sorry about that, I updated the script with str(counter) which should change the format of the counter variable to a string so it will concatenate properly. – Hotpepper May 20 '13 at 17:45
@Hotpepper again, thanks for the help! That corrected the concantenate str and int objects. I'm now getting a "cannot concatenate 'str' and 'set' objects. Any advice? Thanks so much in advance! – Emerson Chew May 21 '13 at 16:28
@Hotpepper I got it man! found another post regarding string and 'set' or 'list' concatenation. I changed states.append('myList') and it worked. Thanks for all your help! – Emerson Chew May 21 '13 at 16:36

If you had a shapefile contained in a folder (note a *.gdb), then Split Layer By Attributes would do the job. In any event, the code contained the scripts associated with the toolbox should provide sufficient background as to how accomplish this task.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.