<?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: select by attribute then export selection (script tool) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284430#M21955</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In order to allow a user to input data you'll need to use arcpy.GetParameterAsText(#). This will allow the script to use the information the use inputs in the tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example...&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
FIPS = arcpy.GetParameterAsText(0)
FIPSlist = arcpy.GetParameterAsTest(1)
SQL = arcpy.GetParameterAsTest(2)
Output = arcpy.GetParameterAsTest(3)

#Rest of code....
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The rest of your code should work the same but you will use the variables in place of the 'hard coded' values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After you have the script done you'll just have to make the script tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This page from the help document should help (the other pages from that section may be useful too).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Adding_a_script_tool/00150000001r000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Adding_a_script_tool/00150000001r000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You'll more less just have to tell the tool where the script is and then setup each parameter with a name and the appropriate data type.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The parameters in the tool properties list corrispond directly to the GetParameterAsText values. So GetParameterAsText(0) will be the 1st row of that section, GetParameterAsText(1) the 2nd and so on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:45:38 GMT</pubDate>
    <dc:creator>BenjaminGale</dc:creator>
    <dc:date>2021-12-11T13:45:38Z</dc:date>
    <item>
      <title>select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284429#M21954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is sort of a continuation of my previous post. &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://forums.arcgis.com/threads/48862-Select-by-attribute-then-exporting-selection" rel="nofollow" target="_blank"&gt;http://forums.arcgis.com/threads/48862-Select-by-attribute-then-exporting-selection&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to create a script tool that does the same thing but with user defined parameters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy FIPS = "C:\\Users\\D2148\\Documents\\Maps\\FIPS" FIPSlist = ('001', '003', '005', '007', '009', '011', '013',&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '015', '017', '019', '021', '023', '025', '027', &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '029', '031', '033', '035', '037', '039', '041', &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '043', '045', '047', '049', '051', '053', '055', &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '057', '059', '061', '063', '065', '067', '069', &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '071', '073', '075', '077', '079', '081', '083', &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '085', '087', '089', '091', '093', '095', '097', &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '099', '101', '103', '105', '107', '109', '111', &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '113', '115', '117', '119', '121', '123', '125', &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '127') for fip in FIPSlist: &amp;nbsp; query = "FIPS_PARIS ='" + fip + "'" &amp;nbsp; arcpy.TableSelect_analysis("Master_TAHI", FIPS + "\\FIPS" + fip + ".dbf",query)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the original script that works, I just need it to take user defined parameters and I have never created a tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- It needs an input dbase, feature class or shapefile (eg. "Master_TAHI")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- A list of attributes the tool needs to loop through (eg. fips = ('001', '003', '005')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- The sql clause (eg. "FIPS_PARIS ='" + fip + "'")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- output with name of attribute at end. (eg. "&lt;/SPAN&gt;&lt;A href="https://community.esri.com/"&gt;\\FIPS&lt;/A&gt;&lt;SPAN&gt;" + fip + ".dbf")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2012 12:02:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284429#M21954</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2012-02-02T12:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284430#M21955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In order to allow a user to input data you'll need to use arcpy.GetParameterAsText(#). This will allow the script to use the information the use inputs in the tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example...&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
FIPS = arcpy.GetParameterAsText(0)
FIPSlist = arcpy.GetParameterAsTest(1)
SQL = arcpy.GetParameterAsTest(2)
Output = arcpy.GetParameterAsTest(3)

#Rest of code....
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The rest of your code should work the same but you will use the variables in place of the 'hard coded' values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After you have the script done you'll just have to make the script tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This page from the help document should help (the other pages from that section may be useful too).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Adding_a_script_tool/00150000001r000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Adding_a_script_tool/00150000001r000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You'll more less just have to tell the tool where the script is and then setup each parameter with a name and the appropriate data type.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The parameters in the tool properties list corrispond directly to the GetParameterAsText values. So GetParameterAsText(0) will be the 1st row of that section, GetParameterAsText(1) the 2nd and so on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:45:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284430#M21955</guid>
      <dc:creator>BenjaminGale</dc:creator>
      <dc:date>2021-12-11T13:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284431#M21956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks and that does help. I got the getparameterastext() part. It's essentially value = input() or value = rawinput(). I guess my problem is the creating the tool part. I have read all the help documents on it and can't make heads or tails on some of it. For instance, on the list portion of my code. I don't know what kind of data type it would be. I haven't been coding for long and haven't gotten the grasp of putting it all together yet.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import sys
import string
import os
fcIn = arcpy.GetParameterAsText(0)
fclist = arcpy.GetParameterAsText(1)
sqlclause = arcpy.GetParameterAsText(2)
fcOut = arcpy.GetParameterAsText(3)
for att in fclist:
&amp;nbsp; arcpy.TableSelect_analysis("fcin", fcin + att + ".dbf",sqlclause)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;This is my work in progress. The other question would be. On the sqlclause portion, how do I get it to loop through the list with a different parameter each time. I can do this in hardcoding with a tuple or list. But the tool is different and I can't seem to link them.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:45:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284431#M21956</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2021-12-11T13:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284432#M21957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This comes up with a error: name 'env' not defined&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import sys
import string
import os
Input = arcpy.GetParameterAsText(0)
Attribute = arcpy.GetParameterAsText(1)
sqlclause = arcpy.GetParameterAsText(2)
env.workspace = arcpy.GetParameterAsText(3)
for att in Attribute:
&amp;nbsp; arcpy.TableSelect_analysis(Input, Input + att, sqlclause)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]11665[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]11664[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:45:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284432#M21957</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2021-12-11T13:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284433#M21958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You just need to add:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 15:39:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284433#M21958</guid>
      <dc:creator>SusanWitherly</dc:creator>
      <dc:date>2012-02-03T15:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284434#M21959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks that got rid of that part. Now it just won't work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #d70019; font-size: 2;"&gt; &amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: ERROR 000210: Cannot create output C:\Users\D2148\Documents\Maps\FIPS\Master_TAHI0&lt;BR /&gt;Failed to execute (TableSelect).&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #d70019; font-size: 2;"&gt;Failed to execute (Selectsplit).&lt;BR /&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 17:02:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284434#M21959</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2012-02-03T17:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284435#M21960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;don't you miss the ".dbf" in the output table??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ciao,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AC&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 17:14:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284435#M21960</guid>
      <dc:creator>AlessandroCinnirella</dc:creator>
      <dc:date>2012-02-03T17:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284436#M21961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yep sure did. As soon as I posted that I knew I missed it. I changed it a few minutes ago and that error went away and brought back a new. &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import sys
import string
import os
from arcpy import env
Input = arcpy.GetParameterAsText(0)
Attribute = arcpy.GetParameterAsText(1)
sqlclause = arcpy.GetParameterAsText(2)
env.workspace = arcpy.GetParameterAsText(3)
for att in Attribute:
&amp;nbsp; arcpy.TableSelect_analysis(Input, Input + att + ".dbf", sqlclause)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="color: #d70019; font-size: 2;"&gt; &amp;lt;type 'exceptions.AttributeError'&amp;gt;: 'module' object has no attribute 'GetParameterAstext'&lt;BR /&gt;Failed to execute (Selectsplit).&lt;BR /&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:45:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284436#M21961</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2021-12-11T13:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284437#M21962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;is it the wole code? because the error means that you have written GetParameterAstext whith a non capital T.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but the code you posted seems ok...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AC&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 17:26:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284437#M21962</guid>
      <dc:creator>AlessandroCinnirella</dc:creator>
      <dc:date>2012-02-03T17:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284438#M21963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;[ATTACH=CONFIG]11685[/ATTACH][ATTACH=CONFIG]11684[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]11687[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]11688[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import sys
import string
import os
from arcpy import env
Input = arcpy.GetParameterAsText(0)
Attribute = arcpy.GetParameterAsText(1)
sqlclause = arcpy.GetParameterAsText(2)
env.workspace = arcpy.GetParameterAsText(3)
for att in Attribute:
&amp;nbsp; arcpy.TableSelect_analysis(Input, Input + att + ".dbf", sqlclause)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;These are copy and pasted exactly how I ran them&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:45:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284438#M21963</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2021-12-11T13:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284439#M21964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;the code seems ok....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;check the source of the script-tool and/or save it with a new name and reload it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 17:39:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284439#M21964</guid>
      <dc:creator>AlessandroCinnirella</dc:creator>
      <dc:date>2012-02-03T17:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284440#M21965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, I saved it under a new name and that seemed to have fixed that. Now, I can see how it is messing up with this error. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]11690[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I do a SQL expression like "FIPS_PARIS" = att or Attribute (calling from the previous parameter list) it literally looks for att or Attribute not 001 or 003&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 17:50:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284440#M21965</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2012-02-03T17:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284441#M21966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;because the sqlclause is defined by the sqlclause = arcpy.GetParameterAsText(2) and it is always the same.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;you use the att only to chancge the output table name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you should modify the scipt in this way&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import sys
import string
import os
from arcpy import env
Input = arcpy.GetParameterAsText(0)
Attribute = arcpy.GetParameterAsText(1)
#sqlclause = arcpy.GetParameterAsText(2)&amp;nbsp; &amp;lt;--- YOU DONT NEED TO SPECIFY THIS PARAMETER
env.workspace = arcpy.GetParameterAsText(2) &amp;lt;---- CHANGE THIS PARAMETER INDEX ACCORDINGLY WITH OTHERS
for att in Attribute:
&amp;nbsp; sqlclause = "\"FIPS_PARIS\" = '" + att + "'"
&amp;nbsp; arcpy.TableSelect_analysis(Input, Input + att + ".dbf", sqlclause)

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;hope this helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AC&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:45:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284441#M21966</guid>
      <dc:creator>AlessandroCinnirella</dc:creator>
      <dc:date>2021-12-11T13:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284442#M21967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yeah I understand that. I am making a tool and want it to have user defined field and attributes. Not just attributes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 18:35:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284442#M21967</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2012-02-03T18:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284443#M21968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;and different expressions other than =&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 18:36:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284443#M21968</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2012-02-03T18:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284444#M21969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ok,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy import sys import string import os from arcpy import env Input = arcpy.GetParameterAsText(0) Attribute = arcpy.GetParameterAsText(1) sqlclause = arcpy.GetParameterAsText(2)&amp;nbsp;&amp;nbsp; env.workspace = arcpy.GetParameterAsText(3)&amp;nbsp; for att in Attribute: &amp;nbsp; sqlclause = sqlclause + "'" + att + "'" &amp;nbsp; arcpy.TableSelect_analysis(Input, Input + att + ".dbf", sqlclause) &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but your sql input parameters should not contain attributes. should be like ("FIPS_PARIS" &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt; or ("CHOSEN_FIELD" CHOSEN_OPERATOR)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AC&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 18:48:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284444#M21969</guid>
      <dc:creator>AlessandroCinnirella</dc:creator>
      <dc:date>2012-02-03T18:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284445#M21970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yep your awesome!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 18:54:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284445#M21970</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2012-02-03T18:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: select by attribute then export selection (script tool)</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284446#M21971</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
import sys
import string
import os
from arcpy import env
Input = arcpy.GetParameterAsText(0)
Attribute = arcpy.GetParameterAsText(1)
Attributelist = Attribute.split(";")
sqlclause = arcpy.GetParameterAsText(2)
env.workspace = arcpy.GetParameterAsText(3)
for att in Attributelist:
&amp;nbsp; query = sqlclause + "'" + att + "'" 
&amp;nbsp; arcpy.TableSelect_analysis(Input, Input + att + ".dbf", query)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Final Code&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:45:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-export-selection-script/m-p/284446#M21971</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2021-12-11T13:45:55Z</dc:date>
    </item>
  </channel>
</rss>

