<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701902#M54391</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Either solution above, slightly adapted, would work for you.&amp;nbsp; If you want to avoid modifying Python code, then you can 'preprocess' what you need manually before feeding into the ready-made tool Dan was talking about above.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, you said you had a single shapefile with a 'year' field which you want to use year ranges with to produce the 'split layers by attributes', so create an extra field in which to code your ranges and select by attributes and code each case you want segregated...once completed, you can run the tool execution to wham bam create the 'split layers', voila!&amp;nbsp; (assuming you are already familiar with 'Select by Attributes' and the 'Field Calculator')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So to be clear, this would be split into 2 by the new field, 'newYrRange':&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;'oldYr', 'newYrRange'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1985, 'before 1990'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1980, 'before 1990'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1776, 'before 1990'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1991, '1990 to 1995'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1994, '1990 to 1995'&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 08 Dec 2012 22:00:00 GMT</pubDate>
    <dc:creator>T__WayneWhitley</dc:creator>
    <dc:date>2012-12-08T22:00:00Z</dc:date>
    <item>
      <title>Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701898#M54387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We have a .shp with thousands of tracts each with specific number (i.e. tract 1, 2, 3....etc). Each tract has multiple contract numbers. (i.e. tract 1 = contract A, B, C...etc.) The contracts are in one field based on the tract number. Many of the contracts share tracts, but we want to see what each contract holds.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;IS there a way to take the contracts and create them as individual shapefiles from the Tract shapefile. For example, we want to take contract A and all of the tracts associated with it to a shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We are new to python and any help would be helpful.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We are using Arc 10 and have version 2.6 of python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2012 19:35:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701898#M54387</guid>
      <dc:creator>MarkFoster1</dc:creator>
      <dc:date>2012-04-10T19:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701899#M54388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Some sample data/screen shots would help with next steps, without knowing details, my best guess would be to do something like this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Get a list of contracts, export to shapefile with a where clause of each contract possibility and export to shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code example, untested.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fc = "C:/GIS/test.shp"
contracts = ["A", "B", "C"]
for cont in contracts:
&amp;nbsp;&amp;nbsp;&amp;nbsp; where = "contractfield like '%"+i+"%'"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion(templayer, exportdir, "somename"+cont+".shp", where)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:31:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701899#M54388</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-12T05:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701900#M54389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Split layers by attributes&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=37AEB018-1422-2418-A036-CA6D9920F808"&gt;http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=37AEB018-1422-2418-A036-CA6D9920F808&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 10:34:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701900#M54389</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2012-04-11T10:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701901#M54390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Any solutions for this yet. I have a similar question though. I have a shapefile with a field year in it. I want to create multiple shapefiles based on the years. For instance a shapefile for all building before 1990, then a shapefile for building before 1995. Any suggestions here ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Dec 2012 21:00:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701901#M54390</guid>
      <dc:creator>SenthilnathanThyagarajan</dc:creator>
      <dc:date>2012-12-08T21:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701902#M54391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Either solution above, slightly adapted, would work for you.&amp;nbsp; If you want to avoid modifying Python code, then you can 'preprocess' what you need manually before feeding into the ready-made tool Dan was talking about above.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, you said you had a single shapefile with a 'year' field which you want to use year ranges with to produce the 'split layers by attributes', so create an extra field in which to code your ranges and select by attributes and code each case you want segregated...once completed, you can run the tool execution to wham bam create the 'split layers', voila!&amp;nbsp; (assuming you are already familiar with 'Select by Attributes' and the 'Field Calculator')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So to be clear, this would be split into 2 by the new field, 'newYrRange':&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;'oldYr', 'newYrRange'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1985, 'before 1990'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1980, 'before 1990'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1776, 'before 1990'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1991, '1990 to 1995'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1994, '1990 to 1995'&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Dec 2012 22:00:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701902#M54391</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-12-08T22:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701903#M54392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the response.I would like to use python so that I can loop the years and then accordingly create shapefiles such as 1990.shp ,1995.shp.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Dec 2012 22:14:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701903#M54392</guid>
      <dc:creator>SenthilnathanThyagarajan</dc:creator>
      <dc:date>2012-12-08T22:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701904#M54393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can still modify Mathew's code.&amp;nbsp; You'd need to set up a SQL query for the year range and substitute that into say a Make Feature Layer, then feed that result into the feature export (think he use Feature Class To Feature Class but I think you can also use Copy Features).&amp;nbsp; You may need to test the queries 1st to make sure they work properly.&amp;nbsp; If it doesn't make the list of query parameters too long, you could conceivably place the entire query strings in there, then call each in turn in the loop.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&amp;nbsp; Actually, I see why Mathew suggested the use of Feature Class To Feature Class - you can enter the SQL query (where_clause) there and make your export in a single line of code - here's the syntax:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;FeatureClassToFeatureClass_conversion (in_features, out_path, out_name, {where_clause}, {field_mapping}, {config_keyword})&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Feature Class To Feature Class (Conversion) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Resource Center » Professional Library » Geoprocessing » Geoprocessing tool reference » Conversion toolbox » To Geodatabase toolset&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001200000020000000"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001200000020000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Dec 2012 22:20:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701904#M54393</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-12-08T22:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701905#M54394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried something like this , but this throws and exception error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
fc = "D:\\2010.shp"
Year = ["1991", "1992", "1997"]
for yr in Year:
&amp;nbsp;&amp;nbsp;&amp;nbsp; where = "contractfield like '%"+1+"%'"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion(fc, "D:\\test output", "somename"+yr+ as integer".shp", where)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:31:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701905#M54394</guid>
      <dc:creator>SenthilnathanThyagarajan</dc:creator>
      <dc:date>2021-12-12T05:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701906#M54395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Bear in mind, that was pseudocode Mathew provided, just a general 'untested' guide... it is good though.&amp;nbsp; Let's take this a step at a time.&amp;nbsp; First, for readability of your code, enclose it with tags,  at the end, and &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; at the beginning.

Forget about the loop and inline substitution for a moment - the 1st priority is to get a single execution of Feature Class To Feature Class going with 1 properly formed query...so do something like this:

&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

# lines preceded with the '#' symbol are comment lines (not code)
# your workspace where all input/output will go for now
arcpy.env.workspace = r'D:\\'

# your input shapefile
inputShp = 'yr2010.shp'&amp;nbsp; # What is your input shapefile?

# your output shapefile
outputShp = 'yr1991.shp'

# where clause -- substitute 'somefield' with your field (keeping the quotes)
# also, is your yr value numeric?
where = "'somefield' = 1991"

# Form Feature Class to Feature Class command based on above params
# FeatureClassToFeatureClass_conversion (in_features, out_path, out_name, {where_clause}, {field_mapping}, {config_keyword})
arcpy.FeatureClassToFeatureClass_conversion(inputShp, arcpy.workspace, outputShp, where) 
&lt;/PRE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:31:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701906#M54395</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-12T05:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701907#M54396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import arcpy
## below is the shapefile which I want to split it into
fc = "D:\\2010.shp" #

#the sql string which I want all the features to be selected for
where = '"Year"&amp;lt;= "1990"'
arcpy.FeatureClassToFeatureClass_conversion(fc, "D:\\test output", "1990.shp", where)

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:31:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701907#M54396</guid>
      <dc:creator>SenthilnathanThyagarajan</dc:creator>
      <dc:date>2021-12-12T05:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701908#M54397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is the error when I run the code :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'module' object has no attribute 'workspace'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;yes the field Year used in Double&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import arcpy

# lines preceded with the '#' symbol are comment lines (not code)
# your workspace where all input/output will go for now
arcpy.env.workspace = r'D:\\test output'

# your input shapefile
inputShp = '"D:\\2010.shp'&amp;nbsp; # What is your input shapefile?

# your output shapefile
outputShp = 'yr1991.shp'

# where clause -- substitute 'somefield' with your field (keeping the quotes)
# also, is your yr value numeric?
where = "'Year' = 1990"

# Form Feature Class to Feature Class command based on above params
# FeatureClassToFeatureClass_conversion (in_features, out_path, out_name, {where_clause}, {field_mapping}, {config_keyword})
arcpy.FeatureClassToFeatureClass_conversion(inputShp, arcpy.workspace, outputShp, where)

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:31:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701908#M54397</guid>
      <dc:creator>SenthilnathanThyagarajan</dc:creator>
      <dc:date>2021-12-12T05:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701909#M54398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try the code you posted again - I think your only problem there was your value was quoted - since it is a double val, remove the quotes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where = '"Year"&amp;lt;= 1990'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...run the below again (I inserted the correction - also, make sure the 'test output' folder exists):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
fc = "D:\\2010.shp"
where = '"Year" &amp;lt;= 1990'
arcpy.FeatureClassToFeatureClass_conversion(fc, "D:\\test output", "1990.shp", where)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:31:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701909#M54398</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-12T05:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701910#M54399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I ran the code above and it creates the 1990.shp perfectly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do i get the loop for all the years so that it creates shapefile for each of the years.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Dec 2012 23:29:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701910#M54399</guid>
      <dc:creator>SenthilnathanThyagarajan</dc:creator>
      <dc:date>2012-12-08T23:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701911#M54400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great, the rest should be relatively easy...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So do you have just a few queries to run?&amp;nbsp; If so, we can save the inline sub for later - what I mean is you can put your whole queries in a list:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;myList = ['strQuery1', 'strQuery2', 'strQuery3']&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then loop on the list as Mathew did... if the code bails on a loop, then you now know it's likely it failed on a where clause...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
myList = ['strQuery1', 'strQuery2', 'strQuery3']

for eachWhere in myList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # execute Feature Class To Feature class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # (substitute 'where' variable with the loop variable, 'eachWhere' [no quotes])
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did forget something critical though - you need something to create dynamically changing output shapefile names so you don't end up overwriting your output.&amp;nbsp; So what you could do is either in-line var substitution or if it is a standard query like the one you already have successfully executed, you could only make a list of the values, say 1990, 1991, etc., and name the shapefiles accordingly...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&amp;nbsp; Okay, the following is just a little bit clunky, but if you want to come up with your own string filenames and you just can't parse it very readily related to vals in your SQL strings, you can do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
outNames = ['name1', 'name2', 'name3']
whereClauses = ['where1', 'where2', 'where3']
for i in range(len(outNames)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion(fc, "D:\\test output", outNames&lt;I&gt;, whereClauses&lt;I&gt;)
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:31:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701911#M54400</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-12T05:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701912#M54401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have to my list of years ready for which I want to create the shapefiles starting from (1991,1992,1996,1998,1999,2000,2003,2004,22005,2006,2008,2010).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So simultaneously I need a shapefile for each of these years. The first one was pretty straightforward but now looping is not that I understand.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Dec 2012 23:59:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701912#M54401</guid>
      <dc:creator>SenthilnathanThyagarajan</dc:creator>
      <dc:date>2012-12-08T23:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701913#M54402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So, make sure I'm understanding, you want individual yearly outputs, correct?&amp;nbsp; If so you only need one list:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;yrs = [1991,1992,1996,1998,1999,2000,2003,2004,2005,2006,2008,2010]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then you can dynamically create both the SQL qry and filenames...as in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for yr in yrs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where = '"Year" &amp;lt;=' + str(yr) + "'"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filename = str(yr) + '.shp'
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, modifying your existing code to add a list variable and loop:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
fc = "D:\\2010.shp"
yrs = [1991,1992,1996,1998,1999,2000,2003,2004,2005,2006,2008,2010]

for yr in yrs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where = '"Year" &amp;lt;=' + str(yr) + "'"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filename = str(yr) + '.shp'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion(fc, "D:\\test output", filename, where)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only problem I see with this is I thought originally you wanted some yr ranges?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:31:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701913#M54402</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-12T05:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701914#M54403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is this how it should be&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
fc = "D:\\2010.shp"
yrs = [1991,1992,1996,1998,1999,2000,2003,2004,2005,2006,2008,2010]
for yr in yrs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where = '"Year" &amp;lt;=' + yr
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filename = str(yr) + '.shp'
arcpy.FeatureClassToFeatureClass_conversion(fc, "D:\\test output", filename, where)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now the error is &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;An invalid SQL statement was used.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;An invalid SQL statement was used.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (FeatureClassToFeatureClass).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:31:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701914#M54403</guid>
      <dc:creator>SenthilnathanThyagarajan</dc:creator>
      <dc:date>2021-12-12T05:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701915#M54404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I just corrected that...see the last post.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is another problem, I forgot about the 'less than or equal to' so you're actually querying for ranges correct?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So that for the 3rd item in the list, 1996, that range would actually be 1992 on, or:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1992 &amp;lt; the range &amp;lt;= 1996&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; - give me a minute.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Dec 2012 00:41:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701915#M54404</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-12-09T00:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701916#M54405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import arcpy
fc = "D:\\2010.shp"
yrs = [1991,1992,1996,1998,1999,2000,2003,2004,2005,2006,2008,2010]
for yr in yrs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where = '"Year" &amp;lt;=' + str(yr) + "'"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filename = str(yr) + '.shp'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion(fc, "D:\\test output", filename, where)

del yr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried the code and it gives me output for just 1991.shp&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:31:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701916#M54405</guid>
      <dc:creator>SenthilnathanThyagarajan</dc:creator>
      <dc:date>2021-12-12T05:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.</title>
      <link>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701917#M54406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, test this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
fc = "D:\\2010.shp"
yrs = [1991,1992,1996,1998,1999,2000,2003,2004,2005,2006,2008,2010]
subtract = ''
for yr in yrs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where = '"Year" &amp;lt;= ' + str(yr) + subtract
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; subtract = ' AND "Year" &amp;gt; ' + str(yr)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filename = str(yr) + '.shp'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion(fc, "D:\\test output", filename, where)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just read your last message...we are almost there, but I must have screwed up on the quotes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Standy by please, this should be a minor fix...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:31:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-many-shapefiles-features-using-python/m-p/701917#M54406</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-12T05:31:42Z</dc:date>
    </item>
  </channel>
</rss>

