<?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 Using a list for selection in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-a-list-for-selection/m-p/622731#M48506</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am using Arc10 SP4.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a script completed for Parcel Noticing, it asks the user to input one parcel number and then runs through the script.&amp;nbsp; We sometimes have to select multiple parcels for noticing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How would I go about starting a script using an excel file or text file that contains a list of parcel numbers?&amp;nbsp; I want to create a script that allows the user the ability to select a file that contains a list of parcel numbers, have the script create a list that can be used in python to do a multiple selection. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;layer = arcpy.GetParameterAsText(0) apnlist = arcpy.GetParameterAsText(1) mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames (mxd, "LAYERS")[0]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What data type parameter property should i use? ie, string or file&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once this is determined, how do I go about turning that input into a list that I can use to create a selection?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am assuming it is going to be a for loop like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;for apn in apnlist: &amp;nbsp;&amp;nbsp;&amp;nbsp; selstring = """TAG = '{0}'""".format(apn) &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION", selstring)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Apr 2012 15:52:50 GMT</pubDate>
    <dc:creator>ChadFoster</dc:creator>
    <dc:date>2012-04-18T15:52:50Z</dc:date>
    <item>
      <title>Using a list for selection</title>
      <link>https://community.esri.com/t5/python-questions/using-a-list-for-selection/m-p/622731#M48506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am using Arc10 SP4.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a script completed for Parcel Noticing, it asks the user to input one parcel number and then runs through the script.&amp;nbsp; We sometimes have to select multiple parcels for noticing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How would I go about starting a script using an excel file or text file that contains a list of parcel numbers?&amp;nbsp; I want to create a script that allows the user the ability to select a file that contains a list of parcel numbers, have the script create a list that can be used in python to do a multiple selection. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;layer = arcpy.GetParameterAsText(0) apnlist = arcpy.GetParameterAsText(1) mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames (mxd, "LAYERS")[0]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What data type parameter property should i use? ie, string or file&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once this is determined, how do I go about turning that input into a list that I can use to create a selection?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am assuming it is going to be a for loop like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;for apn in apnlist: &amp;nbsp;&amp;nbsp;&amp;nbsp; selstring = """TAG = '{0}'""".format(apn) &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION", selstring)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2012 15:52:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-list-for-selection/m-p/622731#M48506</guid>
      <dc:creator>ChadFoster</dc:creator>
      <dc:date>2012-04-18T15:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using a list for selection</title>
      <link>https://community.esri.com/t5/python-questions/using-a-list-for-selection/m-p/622732#M48507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am not 100% sure how to consume an excel document, but a text file or csv is very straight forward.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The input from the user you would need is a path to the text document.&amp;nbsp; I think taking the input as a file returns the path as a string.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;inFile = open("C:\sample.txt", "r")&amp;nbsp; inString = inFile.read() # You change the ", " to whatever is delimiting your numbers in the text file / CSV outList = inString.split(", ")&amp;nbsp; # And then you're right, you would do a for loop on the list to isolate each indiviudal number. for number in outList:&amp;nbsp; print number&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2012 16:16:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-list-for-selection/m-p/622732#M48507</guid>
      <dc:creator>RyanForbes1</dc:creator>
      <dc:date>2012-04-18T16:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using a list for selection</title>
      <link>https://community.esri.com/t5/python-questions/using-a-list-for-selection/m-p/622733#M48508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ryan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the help, it worked great!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Chad&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2012 17:00:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-list-for-selection/m-p/622733#M48508</guid>
      <dc:creator>ChadFoster</dc:creator>
      <dc:date>2012-04-18T17:00:13Z</dc:date>
    </item>
  </channel>
</rss>

