OK, here is the script I wrote a while back, and I just adjusted it for US States, but it will work for any kind of data, as long as it contains a column with unique values.
print 'imports over'
arcpy.env.overwriteOutput = True
# load dataset
states = r"F:\Data\States\States_2010.shp"
# create feature layer
print 'Number of States: ' + str(arcpy.GetCount_management('states_temp'))
for row in arcpy.SearchCursor('states_temp'):
name = str(row.name10)
query = '"name10" = \'' + name + '\''
if " " in name:
name = name.replace(" ", "")
arcpy.CopyFeatures_management('states_temp',r"F:\randomGISstuff\states\exports\\" + name + ".shp")
How this works (simplified explanation; just the basic steps, not line by line):
- loop through the file, and for each feature get its name
- use that name to then select the row, and export just that row (i.e. that feature)
- when exporting use the name as the new file's name
This works well and fast. It also takes care of names that would have spaces in them. For example, North Carolina would be exported to NorthCarolina.shp instead of North Carolina.shp.
To illustrate this (and I apologize, these screenshots will be coming from QGIS... ArcGIS license has expired at home):
I have a shapefile of the USA:
Now, I would like to use the column NAME10 to use as the names for my exported files:
After running the script I will be left with this, all of them separate datasets:
Now, specifically to get it to work with your data, as you have not done any coding before, there are some parts you need to adjust.
I would recommend copy/pasting this code to a text editor or an IDE, such as Notepad++ or PyScripter, respectively. Save it as a file with a py extension, such as featuresToShp.py.
Then you need to edit the following lines:
7: insert the path to your dataset
15 and 16: change NAME10 to the field in your dataset that contains the state names
23: insert the path where you want to save your new files (the path/folder needs to exist before running the script!)
Then save, double click your .py file, and see the files magically appear in your specified folder :-)