<?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: Expression for select by attribute in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/expression-for-select-by-attribute/m-p/547185#M42697</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I also tried&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #000000;"&gt;ProcessedData = str(ProcessedData)[1:-1]&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #000000;"&gt;expression = "LineName IN (" + &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;ProcessedData&lt;/SPAN&gt;+ ")" &lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #000000;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #000000;"&gt;still same error&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Apr 2015 08:25:51 GMT</pubDate>
    <dc:creator>NaimeCelik</dc:creator>
    <dc:date>2015-04-29T08:25:51Z</dc:date>
    <item>
      <title>Expression for select by attribute</title>
      <link>https://community.esri.com/t5/python-questions/expression-for-select-by-attribute/m-p/547182#M42694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I have unique list&amp;nbsp; like &lt;SPAN style="color: #000000; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;ProcessedData=&lt;/SPAN&gt;["Line1","Line17","Line&lt;SPAN style="line-height: 1.5;"&gt;76&lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5;"&gt;"....] and I have a point data in which every point has the line name they belong to in its attribute table. I want to select those points based on their line names but only the ones in that unique list. I am applying the python code below but processing is very slow. I need to select 10000 lines and the process is very slow with the code below. Is there any other way of writing the expression so that it selects them in same time instead of one by one in a for loop ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for item in ProcessedData:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Expression= "\"LineName\" = "+ "'"+item+"'"&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management ("PointData", "ADD_TO_SELECTION", Expression)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 11:49:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/expression-for-select-by-attribute/m-p/547182#M42694</guid>
      <dc:creator>NaimeCelik</dc:creator>
      <dc:date>2015-04-28T11:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Expression for select by attribute</title>
      <link>https://community.esri.com/t5/python-questions/expression-for-select-by-attribute/m-p/547183#M42695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Naime,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of iterating through your list with a 'for' loop, try using '&lt;A href="http://support.esri.com/en/knowledgebase/techarticles/detail/32024" rel="nofollow noopener noreferrer" target="_blank"&gt;IN&lt;/A&gt;' within your expression to select multiple values.&amp;nbsp; Ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;list = ['Alabama', 'Arizona']
list = str(list)[1:-1]
expression = "State_Name IN (" + list + ")"

arcpy.SelectLayerByAttribute_management("COUNTIES", "NEW_SELECTION", expression)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:40:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/expression-for-select-by-attribute/m-p/547183#M42695</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T23:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Expression for select by attribute</title>
      <link>https://community.esri.com/t5/python-questions/expression-for-select-by-attribute/m-p/547184#M42696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jake,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your reply. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I inserted my expression as you indicated &lt;/P&gt;&lt;P&gt;ProcessedData = str(ProcessedData)[1:-1]&lt;/P&gt;&lt;P&gt;expression = "LineName (" + &lt;SPAN style="color: #000000; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;ProcessedData&lt;/SPAN&gt;+ ")"&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got error as below, why do you think this happens?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 000358: Invalid expression&lt;/P&gt;&lt;P&gt;Failed to execute (SelectLayerByAttribute)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 08:05:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/expression-for-select-by-attribute/m-p/547184#M42696</guid>
      <dc:creator>NaimeCelik</dc:creator>
      <dc:date>2015-04-29T08:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Expression for select by attribute</title>
      <link>https://community.esri.com/t5/python-questions/expression-for-select-by-attribute/m-p/547185#M42697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I also tried&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #000000;"&gt;ProcessedData = str(ProcessedData)[1:-1]&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #000000;"&gt;expression = "LineName IN (" + &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;ProcessedData&lt;/SPAN&gt;+ ")" &lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #000000;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #000000;"&gt;still same error&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 08:25:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/expression-for-select-by-attribute/m-p/547185#M42697</guid>
      <dc:creator>NaimeCelik</dc:creator>
      <dc:date>2015-04-29T08:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Expression for select by attribute</title>
      <link>https://community.esri.com/t5/python-questions/expression-for-select-by-attribute/m-p/547186#M42698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hello Jake &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just realized that the problem was encoding in the list items were look like&amp;nbsp; u'Line1'&amp;nbsp; after turning each item &lt;/P&gt;&lt;P&gt;ProcessedData=[str(x) for x in ProcessedData]&lt;/P&gt;&lt;P&gt;then it worked very well &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp; Thank you so much for your answer &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 08:45:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/expression-for-select-by-attribute/m-p/547186#M42698</guid>
      <dc:creator>NaimeCelik</dc:creator>
      <dc:date>2015-04-29T08:45:19Z</dc:date>
    </item>
  </channel>
</rss>

