<?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 exporting selection in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526366#M41223</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm new to Python and what I want to do is very similar, only my list is of integer values (created by using range()). Using the above example, how would the query expression be changed if FIPSlist was integer instead of string (query field is also integer)?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Feb 2012 22:10:41 GMT</pubDate>
    <dc:creator>AmySwan</dc:creator>
    <dc:date>2012-02-21T22:10:41Z</dc:date>
    <item>
      <title>Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526350#M41207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;arcpy.TableToTable_conversion("Master_TAHI", &lt;/SPAN&gt;&lt;SPAN style="font-size: 2;"&gt;"C:\\Users\\D2148\\Documents\\Maps\\Parish Roads\\TAHI_LRS\\Parish_roads\\TAHI_parish\\FIPS", "FIPS001", "\"FIPS PARIS\" = '001'")&lt;BR /&gt;&lt;BR /&gt;I am trying to select by attributes in a .dbf table then export it out to a new .dbf with the selected features only. I am having a problem executing this file. It keeps saying there is a error. The maximum record length has been exceeded. The file only has 87000 records. &lt;BR /&gt;&lt;BR /&gt;Also, once this is figured out. How do I continue to go to the next select by attribute using a while statement. I need it to go to the FIPS PARIS = 127 and each FIPS is odd starting with 001 (eg. 001,003,005...)&lt;BR /&gt;&lt;BR /&gt;If the table to table way doesn't work, any suggestions would be helpful. Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 13:30:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526350#M41207</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2012-01-30T13:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526351#M41208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, to start; neither your input nor output is a obviously a dBase file. A dBase file has a .dbf extension.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Arc has to be told you are working with a dbase input and expect a dBase output.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 14:06:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526351#M41208</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2012-01-30T14:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526352#M41209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is used inside of arcmap, the master tahi file was selected in the python window from drop down and the output I changed to "FIPS001.dbf", This still did not work. So, what I did was run it through the toolbox command with the window pop up and did the same parameters. This still came up with the exceeded records error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 14:16:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526352#M41209</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2012-01-30T14:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526353#M41210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not sure the changes I made to your TableToTable command will solve the error you're getting, but here is how you can set up a loop for all odd numbers from 1 to 127. It will make the appropriate changes to the output file name, and the where clause:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for i in range(1,129,2):
&amp;nbsp;&amp;nbsp;&amp;nbsp; fipString=str(i).zfill(3)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.TableToTable_conversion("Master_TAHI", "C:\\Users\\D2148\\Documents\\Maps\\Parish Roads\\TAHI_LRS\\Parish_roads\\TAHI_parish\\FIPS", "FIPS%s.dbf" % fipString, "\"FIPS PARIS\" = '%s'" % fipString)

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526353#M41210</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2021-12-11T22:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526354#M41211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;FIPS = "C:\\Users\\D2148\\Documents\\Maps\\FIPS"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color:#ff0000;"&gt;# I changed the destination for a shorter path name&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;c = 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FIPSlist = ['001', '003', '005', '007', '009', '011', '013',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '015', '017', '019', '021', '023', '025', '027',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '029', '031', '033', '035', '037', '039', '041',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '043', '045', '047', '049', '051', '053', '055',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '057', '059', '061', '063', '065', '067', '069',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '071', '073', '075', '077', '079', '081', '083',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '085', '087', '089', '091', '093', '095', '097',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '099', '101', '103', '105', '107', '109', '111',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '113', '115', '117', '119', '121', '123', '125',&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '127']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while c &amp;lt; len(FIPSlist):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.TableToTable_conversion("Master_TAHI",FIPS,"FIPS" + FIPSlist&lt;C&gt; + ".dbf","FIPS_PARIS" = &lt;/C&gt;&lt;/SPAN&gt;&lt;SPAN style="color:#ff0000;"&gt;"'" + FIPSlist&lt;C&gt; + "'"&lt;/C&gt;&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN style="color:#ff0000;"&gt; #I'm thinking this is the problem with to many ", but I need it to automate choosing the next number. I also think that it is a string and the program won't take it. &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = c + 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is what I came up with because the number part would not be correct because it needs the 001,003, 005 and so forth. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This code comes up with &lt;/SPAN&gt;&lt;SPAN style="color: #e60000; font-size: 5;"&gt;&lt;BR /&gt;Runtime error &amp;lt;type 'exceptions.SyntaxError'&amp;gt;: keyword can't be an expression (&amp;lt;string&amp;gt;, line 14)&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #e60000; font-size: 5;"&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 16:00:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526354#M41211</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2012-01-30T16:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526355#M41212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I also tried your way bruce but it did not work&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 16:48:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526355#M41212</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2012-01-30T16:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526356#M41213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;. I am having a problem executing this file. It keeps saying there is a error. The maximum record length has been exceeded. The file only has 87000 records. &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error has to do with the record length, not the number of records. Dbase tables have some pretty serious limitations compared to GDB tables -- I suspect that is your issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Field names cannot be longer than 10 characters.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;The maximum record length for an attribute is 4,000 bytes. The record length is the number of bytes used to define all the fields, not the number of bytes used to store the actual values.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;The maximum number of fields is 255. A conversion to shapefile will convert the first 255 fields if this limit is exceeded.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;The dBASE file must contain at least one field. When you create a new shapefile or dBASE table, an integer ID field is created as a default.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;dBASE files do not support type blob, guid, global ID, coordinate ID, or raster field types.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;dBASE files have little SQL support aside from a WHERE clause.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Attribute indexes are deleted when you save edits, and you must re-create them from scratch.&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002t0000000m000000.htm"&gt;Arc 10 Help: Geoprocessing considerations for shapefile output&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 17:25:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526356#M41213</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-01-30T17:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526357#M41214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How about:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;inputTable = r"C:\temp\test\mytable.dbf"
outputWorkspace = r"C:\temp\test"
fipsLlist = ['001', '003', '005', '007', '009', '011', '013', 
'015', '017', '019', '021', '023', '025', '027', 
'029', '031', '033', '035', '037', '039', '041', 
'043', '045', '047', '049', '051', '053', '055', 
'057', '059', '061', '063', '065', '067', '069', 
'071', '073', '075', '077', '079', '081', '083', 
'085', '087', '089', '091', '093', '095', '097', 
'099', '101', '103', '105', '107', '109', '111', 
'113', '115', '117', '119', '121', '123', '125', 
'127']
for fip in fipsList:
&amp;nbsp;&amp;nbsp; arcpy.TableSelect_analysis(inputTable, outputWorkspace + "\\fips_" + str(fip) + ".dbf", ","FIPS_PARIS = " +&amp;nbsp; "'" + fip + "'")&amp;nbsp; &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526357#M41214</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T22:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526358#M41215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I ran my most recent code and got the correct outcome except the fact it did not select the attributes needed for each file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i just tried the code without the "FIPS_PARISH" = '', attribute selection. It created the files correctly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 17:29:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526358#M41215</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2012-01-30T17:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526359#M41216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;How about:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;inputTable = r"C:\temp\test\mytable.dbf"
outputWorkspace = r"C:\temp\test"
fipsLlist = ['001', '003', '005', '007', '009', '011', '013', 
'015', '017', '019', '021', '023', '025', '027', 
'029', '031', '033', '035', '037', '039', '041', 
'043', '045', '047', '049', '051', '053', '055', 
'057', '059', '061', '063', '065', '067', '069', 
'071', '073', '075', '077', '079', '081', '083', 
'085', '087', '089', '091', '093', '095', '097', 
'099', '101', '103', '105', '107', '109', '111', 
'113', '115', '117', '119', '121', '123', '125', 
'127']
for fip in fipsList:
&amp;nbsp;&amp;nbsp; arcpy.TableSelect_analysis(inputTable, outputWorkspace + "\\fips_" + str(fip) + ".dbf", ","FIPS_PARIS = " +&amp;nbsp; "'" + fip + "'")&amp;nbsp; &lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;arc doesn't recognize the last part as an expression, just as a string.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526359#M41216</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2021-12-11T22:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526360#M41217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Still having problems with the where clause. The select features will not go through the list loop. It only wants to find the list name since it is in quotes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I just can't figure this out.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 14:16:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526360#M41217</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2012-02-01T14:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526361#M41218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your code gives me a syntax error so it definitely won't run if that is what you are using.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This should be your where-clause I believe.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;"FIPS_PARIS = '" + fip + "'"&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 14:41:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526361#M41218</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-02-01T14:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526362#M41219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Still having problems with the where clause. The select features will not go through the list loop. It only wants to find the list name since it is in quotes.&lt;BR /&gt;I just can't figure this out.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You've got a syntax error. I highly recommend using a syntax checker. Corrected (using escapes for the single quotes -- just for clarity)&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.TableSelect_analysis(inputTable, outputWorkspace +\
&amp;nbsp;&amp;nbsp;&amp;nbsp; "\\fips_" + str(fip) + ".dbf", \
&amp;nbsp;&amp;nbsp;&amp;nbsp; "FIPS_PARIS = " +&amp;nbsp; "\'" + fip + "\'")
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Using &lt;/SPAN&gt;&lt;A href="http://docs.python.org/library/stdtypes.html#string-formatting" rel="nofollow noopener noreferrer" target="_blank"&gt;string formatting &lt;/A&gt;&lt;SPAN&gt; and the os.path module to construct paths is a lot easier to code and debug:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
query = "FIPS_PARIS = \'%s\'" % fip
outTable = os.path.join(outputWorkspace,"fips_%s.dbf" % fip)
arcpy.TableSelect_analysis(inputTable,outTable,query)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;And there is a &lt;/SPAN&gt;&lt;A href="http://docs.python.org/tutorial/inputoutput.html#fancier-output-formatting" rel="nofollow noopener noreferrer" target="_blank"&gt;new string format() method&lt;/A&gt;&lt;SPAN&gt; (introduced in Python 2.4) that will eventually replace it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
query = "FIPS_PARIS = \'{0}\'".format(fip)
outTable = os.path.join(outputWorkspace,"fips_{0}.dbf".format(fip)
arcpy.TableSelect_analysis(inputTable,outTable, query)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526362#M41219</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T22:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526363#M41220</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
FIPS = "C:\\Users\\D2148\\Documents\\Maps\\FIPS"
c = 0
# FIPSlist = ('001', '003', '005', '007', '009', '011', '013', #Try smaller list first
&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')
#FIPSnum = (001, 003, 005, 007, 009, 011, 013, #Try Smaller list first
&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; # 029, 031, 033, 035, 037, 039, 041,
&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; # 057, 059, 061, 063, 065, 067, 069,
&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; # 085, 087, 089, 091, 093, 095, 097,
&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; # 113, 115, 117, 119, 121, 123, 125,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # 127)
FIPSlist = ('001', '003', '005')
FIPSnum = (001, 003, 005)
while c &amp;lt; len(FIPSlist):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fip in FIPSlist:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query = "FIPS_PARIS ='" + fip + "'"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # arcpy.TableToTable_conversion("TRIAL1",FIPS,"FIPS" + FIPSlist&lt;C&gt; + ".dbf",query)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.TableSelect_analysis("Master_TAHI", FIPS + "&lt;A href="https://community.esri.com/" rel="nofollow noopener noreferrer" target="_blank"&gt;\\FIPS&lt;/A&gt;" + FIPSlist&lt;C&gt; + ".dbf",query)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = c + 1&lt;/C&gt;&lt;/C&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;I think this will work as it was trying to work and made the first file correct. However, it will not loop anymore&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526363#M41220</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2021-12-11T22:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526364#M41221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; However, it will not loop anymore&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your loop is incorrect. You don't need a counter or while loop.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;FIPSlist = ('001', '003', '005') for fip in FIPSlist: &amp;nbsp;&amp;nbsp;&amp;nbsp; query = "FIPS_PARIS ='" + fip + "'" &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.TableSelect_analysis("Master_TAHI", FIPS + r"\FIPS" + fip + ".dbf",query)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 16:20:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526364#M41221</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-02-01T16:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526365#M41222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It finally worked! Thank you so much!&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&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; '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 + "&lt;A href="https://community.esri.com/" rel="nofollow noopener noreferrer" target="_blank"&gt;\\FIPS&lt;/A&gt;" + fip + ".dbf",query)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;This worked great. The thing is... I tried this combo many times. I think it was the placement of the " or '.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526365#M41222</guid>
      <dc:creator>NathanBaylot1</dc:creator>
      <dc:date>2021-12-11T22:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526366#M41223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm new to Python and what I want to do is very similar, only my list is of integer values (created by using range()). Using the above example, how would the query expression be changed if FIPSlist was integer instead of string (query field is also integer)?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 22:10:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526366#M41223</guid>
      <dc:creator>AmySwan</dc:creator>
      <dc:date>2012-02-21T22:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526367#M41224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm new to Python and what I want to do is very similar, only my list is of integer values (created by using range()). Using the above example, how would the query expression be changed if FIPSlist was integer instead of string (query field is also integer)?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just do it without the quotes. Also, to use the integer as part of the expression you need to convert the number to a string, using str() too:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
FIPSlist = range(5) # (0,1,2,3,4)
for fip in FIPSlist:
&amp;nbsp;&amp;nbsp;&amp;nbsp; query = "FIPS_PARIS = " + str(fip)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.TableSelect_analysis("Master_TAHI", FIPSpath + r"\FIPS" + str(fip) + ".dbf",query)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:55:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526367#M41224</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T22:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526368#M41225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How about:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
myOutputTable = r"C:\temp\test.gdb\input"
for i in range(1,1001):
&amp;nbsp;&amp;nbsp; myOutputTable = r"C:\temp\test.gdb\table_id_" + str(i)
&amp;nbsp;&amp;nbsp; arcpy.TableSelect_analysis(myInputTable, myOutputTable, "MY_ID = " + str(i))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:56:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526368#M41225</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T22:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Select by attribute then exporting selection</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526369#M41226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello! i think my question is simple but i can not find a way on answering it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I want&amp;nbsp; to make a query in attribute table(arcmap) in which i will get the results for the maximum value of a column.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a table with 4 columns [District] [total number of schools] [students] [name of schools], i am interested to get the result from the column students, since the question is 'which district has the most students'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How can i represend in arcmap the value max?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2012 15:14:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-then-exporting-selection/m-p/526369#M41226</guid>
      <dc:creator>sofiatavantzi</dc:creator>
      <dc:date>2012-09-21T15:14:14Z</dc:date>
    </item>
  </channel>
</rss>

