<?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: Python Script for Field Search in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-for-field-search/m-p/501681#M39397</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jake,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the help! I tried that code with some modification to my data and it worked for two fields. Only thing i have and issue with is that I have over 50 fields to search through. Is there a way to stream line this code with out writing out each field multiple times?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Justin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Dec 2013 20:54:39 GMT</pubDate>
    <dc:creator>JustinCrowther1</dc:creator>
    <dc:date>2013-12-11T20:54:39Z</dc:date>
    <item>
      <title>Python Script for Field Search</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-field-search/m-p/501679#M39395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am looking to figure out a python script to automate, in field calculator, looking through multiple fields and providing a Yes if data is present.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Context:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a Feature Class for permitted sections. This feature class has multiple permits; and the permits can cover multiple sections. I am looking to create one field that indicates if the section has a permit, regardless of the permit type. I cannot figure out the script to automate this process.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions would be greatly appreciated. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Justin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 17:16:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-field-search/m-p/501679#M39395</guid>
      <dc:creator>JustinCrowther1</dc:creator>
      <dc:date>2013-12-11T17:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script for Field Search</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-field-search/m-p/501680#M39396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Justin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could use the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
fc = "permits"

with arcpy.da.UpdateCursor(fc, ["Permit1", "Permit2", "HasPermit"], "NOT Permit1 IS NULL OR NOT Permit2 IS NULL") as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[2] = "YES"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)

del cursor, row&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What the code does is search through the permit fields (i.e. Permit1, Permit2) and if any of them have a value it will populate the 'HasPermit' field with a value of YES.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If your data does not have NULL values, you will have to update the query to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NOT Permit1 = '' OR NOT Permit2 = ''&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:00:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-field-search/m-p/501680#M39396</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T22:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script for Field Search</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-field-search/m-p/501681#M39397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jake,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the help! I tried that code with some modification to my data and it worked for two fields. Only thing i have and issue with is that I have over 50 fields to search through. Is there a way to stream line this code with out writing out each field multiple times?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Justin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 20:54:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-field-search/m-p/501681#M39397</guid>
      <dc:creator>JustinCrowther1</dc:creator>
      <dc:date>2013-12-11T20:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script for Field Search</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-field-search/m-p/501682#M39398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can iterate through the fields and only search the permit fields.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;fc = "permits"&amp;nbsp; for field in arcpy.ListFields(fc): &amp;nbsp;&amp;nbsp;&amp;nbsp; #Specify all none permit fields &amp;nbsp;&amp;nbsp;&amp;nbsp; if field.name != "OBJECTID" and field.name != "Shape" and field.name != "Shape_Length" and field.name != "Shape_Area" and field.name != "GlobalID" and field.name != "HasPermit": &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.UpdateCursor(fc, [field.name, "HasPermit"], "NOT " + field.name + " IS NULL") as cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #if query is valid, set hasValue variable to 'true' &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hasValue = 'true' &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if hasValue == 'true': &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; for row in cursor: &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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = "YES" &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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row) &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; hasValue = 'false'&amp;nbsp; del cursor, row&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Dec 2013 10:34:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-field-search/m-p/501682#M39398</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2013-12-12T10:34:36Z</dc:date>
    </item>
  </channel>
</rss>

