<?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: Problems using the where clause with searchcursor method in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140298#M10932</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you use the Make Feature Layer against the where clause you are trying to use in arcmap?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The tool can be found in arctoolbox -&amp;gt; data management tools -&amp;gt; Layers and Table Views -&amp;gt; Make Feature Layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try copying and pasting that where clause for use of the update cursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, are you the only person using this dataset?&amp;nbsp; You need to be able to get an exclusive data lock on your datasets.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Jul 2011 15:48:20 GMT</pubDate>
    <dc:creator>AndrewChapkowski</dc:creator>
    <dc:date>2011-07-29T15:48:20Z</dc:date>
    <item>
      <title>Problems using the where clause with searchcursor method</title>
      <link>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140290#M10924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using ArcGIS Desktop 10.0 and I am&amp;nbsp; trying to write a script in python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am having problems with the where clause in the searchcursor method.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically I have a CAD file and would like to identify from the CAD file all of the Annotations that have been flagged with a&amp;nbsp; ??????? question mark.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So if I have the following list of Annotations in the Text filed of the Annotation CAD feature class, I would like to pull out the 3rd 5th and 6th rows using search cursor:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;33334508&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;33304576&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;?97464800&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;64538300&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;?74537390&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;?64849300&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have managed to get the where clause in the search cursor to identify individual records but it keeps failing.&amp;nbsp; I have attached an example of the CAD file and also the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe that the problem may be that the ???question mark??? is confusing the where clause.&amp;nbsp; I have tried to escape the non standard characters and also writing the where clause as a variable but do not seem to be getting anywhere.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If anyone could help it would be really appreciated, I copy my script below......&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kevin&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = r"C:\CADfile.dwg"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#This does not work: cur = arcpy.SearchCursor("Annotation",'LEFT("Text",1)='[\\?]'',"","","")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#This works: cur = arcpy.SearchCursor("Annotation","\"Text\" = \'69570020\'")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#This works: cur = arcpy.SearchCursor("Annotation",'"Text" &amp;lt; \'1\'')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cur = arcpy.SearchCursor("Annotation",'\"Text\" LIKE \'\?\%\'\')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Iterate through the rows in the cursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in cur:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Layer: %s,&amp;nbsp; Parcel: %s" % \&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (row.Layer, row.Text)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;del cur, row&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 05:25:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140290#M10924</guid>
      <dc:creator>KevinCressy</dc:creator>
      <dc:date>2011-03-02T05:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the where clause with searchcursor method</title>
      <link>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140291#M10925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try not putting the field name in quotes and the like statement should work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is what I did to get it to work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

expression = "Text LIKE '?%'"

cadFile = r"c:\temp\CADfile.dwg\Annotation"

cursor = arcpy.SearchCursor(cadFile, expression)

for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.getValue("Text")

del row, cursor

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Result:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; 
?69570190
?69570430
?69570440
?69570550
&amp;gt;&amp;gt;&amp;gt; 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:44:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140291#M10925</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2021-12-11T07:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the where clause with searchcursor method</title>
      <link>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140292#M10926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thats great - thanks it worked!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 15:08:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140292#M10926</guid>
      <dc:creator>KevinCressy</dc:creator>
      <dc:date>2011-03-03T15:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the where clause with searchcursor method</title>
      <link>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140293#M10927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;can you give some examples for using: &lt;/SPAN&gt;&lt;STRONG&gt;cursor = arcpy.UpdateCursor(FC, &lt;SPAN style="text-decoration:underline;"&gt;expression&lt;/SPAN&gt;)&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;with: shape files&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;with: geodatabase (*.gdb) FC&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;with: geodatabase (*.mdb) FC&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;with: *dbf tables&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I stil have problems in preparing the where_clause for the UpdateCursor and SearchCursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can't understand the syntax.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2011 05:07:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140293#M10927</guid>
      <dc:creator>GraziaZulian</dc:creator>
      <dc:date>2011-03-04T05:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the where clause with searchcursor method</title>
      <link>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140294#M10928</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;Here are some links that explain the syntax a little better from the web help:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s500000033000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s500000033000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Building_a_query_expression/00s50000002t000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Building_a_query_expression/00s50000002t000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrew&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2011 09:23:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140294#M10928</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2011-03-04T09:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the where clause with searchcursor method</title>
      <link>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140295#M10929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Andrew,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've reviewed the links you posted over and over, and I still cannot get the UpdateCursor to work with a where clause. I am trying to take a selection and do a find and replace on only that selection. The script runs when done without the where clause; but updates the entire feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set environment settings&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = "H:/PythonMSAG/P1_staging.mdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set local variables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inFeatures = "Address_Points"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cur3 = arcpy.UpdateCursor(inFeatures, '[CITY_ID]=\'KAUK\'')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;RESULTS in this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "H:\PythonMSAG\findreplace1.py", line 72, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; del cur3, row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NameError: name 'row' is not defined&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in cur3:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.MSAG_NAME = string.replace(row.MSAG_NAME, "FOURTH", "4")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur3.updateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del cur3, row&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 15:01:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140295#M10929</guid>
      <dc:creator>LukeBehling</dc:creator>
      <dc:date>2011-07-29T15:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the where clause with searchcursor method</title>
      <link>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140296#M10930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It looks like you might have an incorrect where statement in your code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
where =&amp;nbsp; "[CITY_ID]=\"KAUK\""
cur3 = arcpy.UpdateCursor(inFeatures, where)

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:44:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140296#M10930</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2021-12-11T07:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the where clause with searchcursor method</title>
      <link>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140297#M10931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It still doesn't work. I've tried a Personal (9.3.1) and File geodatabase (10). It seems like no matter what I put in the where clause, it fails.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 15:32:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140297#M10931</guid>
      <dc:creator>LukeBehling</dc:creator>
      <dc:date>2011-07-29T15:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the where clause with searchcursor method</title>
      <link>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140298#M10932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you use the Make Feature Layer against the where clause you are trying to use in arcmap?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The tool can be found in arctoolbox -&amp;gt; data management tools -&amp;gt; Layers and Table Views -&amp;gt; Make Feature Layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try copying and pasting that where clause for use of the update cursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, are you the only person using this dataset?&amp;nbsp; You need to be able to get an exclusive data lock on your datasets.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 15:48:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140298#M10932</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2011-07-29T15:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the where clause with searchcursor method</title>
      <link>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140299#M10933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay, figured it out, the attribute code was different. KAUK should have been KAUC. WHERE clause was correct.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 18:56:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-using-the-where-clause-with-searchcursor/m-p/140299#M10933</guid>
      <dc:creator>LukeBehling</dc:creator>
      <dc:date>2011-07-29T18:56:53Z</dc:date>
    </item>
  </channel>
</rss>

