<?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: I get invalid syntax in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493895#M38744</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Extra bracket in 23.&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt; row.setValue("test", (row.getValue(field))&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Change it to: row.setValue("test", row.getValue(field))&lt;/P&gt;&lt;P&gt;Also, consider using arcpy.da.Search/InsertCursor instead of arcpy.Search/InsertCursor, the new (at 10.1) cursors are much faster and have easier and more "pythonic" syntax.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Mar 2016 02:42:38 GMT</pubDate>
    <dc:creator>Luke_Pinner</dc:creator>
    <dc:date>2016-03-10T02:42:38Z</dc:date>
    <item>
      <title>I get invalid syntax</title>
      <link>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493894#M38743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;I 'm trying to run my script but I get this error message.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="syntax.jpg" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/190495_syntax.jpg" style="width: 620px; height: 294px;" /&gt;&lt;/P&gt;&lt;P&gt; Here is the code.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;import arcpy&lt;/LI&gt;&lt;LI&gt;from arcpy import env&lt;/LI&gt;&lt;LI&gt;env.workspace = r'D:\Eric\Ejercicio\shp\ejercicioTest.gdb\shp'&lt;/LI&gt;&lt;LI&gt;crbuff = r'D:\Eric\Ejercicio\shp\ejercicioTest.gdb\shp\CRojaPBuff'&lt;/LI&gt;&lt;LI&gt;insumo = r'D:\Eric\Ejercicio\shp\ejercicioTest.gdb\shp\Insumo'&lt;/LI&gt;&lt;LI&gt;&lt;/LI&gt;&lt;LI&gt;# Add field to insumo.&lt;/LI&gt;&lt;LI&gt;arcpy.AddField_management(insumo, "test", "TEXT", "", "", "50", "", "NULLABLE", "NON_REQUIRED", "")&lt;/LI&gt;&lt;LI&gt;&lt;/LI&gt;&lt;LI&gt;# Make a layer from crbuff to get the select by location works.&lt;/LI&gt;&lt;LI&gt;arcpy.MakeFeatureLayer_management (crbuff, 'crbuff_layer')&lt;/LI&gt;&lt;LI&gt;arcpy.MakeFeatureLayer_management (insumo, 'insumo_layer')&lt;/LI&gt;&lt;LI&gt;&lt;/LI&gt;&lt;LI&gt;# loop with cursor&lt;/LI&gt;&lt;LI&gt;cursor = arcpy.SearchCursor(crbuff)&lt;/LI&gt;&lt;LI&gt;field = "Lab" # Specify the field in the loop.&lt;/LI&gt;&lt;LI&gt;for row in cursor:&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print (row.getValue(field))&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management('insumo_layer', "HAVE_THEIR_CENTER_IN", 'crbuff_layer', "", "NEW_SELECTION", "NOT_INVERT")&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Calculate Field.&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursorIn = arcpy.UpdateCursor('insumo_layer')&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursorIn:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/LI&gt;&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue("test", (row.getValue(field))&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursorIn.updateRow(row)&lt;/LI&gt;&lt;LI&gt;&lt;/LI&gt;&lt;LI&gt;# Process: Summary Statistics.&lt;/LI&gt;&lt;LI&gt;intable = r'D:\Eric\Ejercicio\shp\Insumo.shp'&lt;/LI&gt;&lt;LI&gt;outtable = r'D:\Eric\Ejercicio\shp'&lt;/LI&gt;&lt;LI&gt;arcpy.Statistics_analysis(intable, outtable + "stats.dbf", "POB1 SUM;POB8 SUM;POB11 SUM;POB14 SUM;POB15 SUM;POB16 SUM;POB24 SUM;POB31 SUM;POB57 SUM;MIG7 SUM;INDI1 SUM;DISC1 SUM;DISC4 SUM;DISC5 SUM;DISC6 SUM;ECO1 SUM;ECO4 SUM;ECO25 SUM;ECO28 SUM;SALUD1 SUM;SALUD2 SUM;SALUD3 SUM;SALUD4 SUM;SALUD5 SUM;SALUD6 SUM", "test")&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I need help ...&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/silly.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 02:19:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493894#M38743</guid>
      <dc:creator>G__EricCastillo_Morales</dc:creator>
      <dc:date>2016-03-10T02:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: I get invalid syntax</title>
      <link>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493895#M38744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Extra bracket in 23.&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt; row.setValue("test", (row.getValue(field))&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Change it to: row.setValue("test", row.getValue(field))&lt;/P&gt;&lt;P&gt;Also, consider using arcpy.da.Search/InsertCursor instead of arcpy.Search/InsertCursor, the new (at 10.1) cursors are much faster and have easier and more "pythonic" syntax.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 02:42:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493895#M38744</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2016-03-10T02:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: I get invalid syntax</title>
      <link>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493896#M38745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Luke, nice catch. Also, how do you know when to use arcpy.da.SearchCursor versus using arcpy.SearchCursor?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 02:47:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493896#M38745</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2016-03-10T02:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: I get invalid syntax</title>
      <link>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493897#M38746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In most cases I would recommend using the da cursors, since they are much faster. I can only think of a few use cases for the "old" cursors like accessing the attribute table of the integer raster data set or when using ArcGIS 10.0. There is some more info here: &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/python/data-access-using-cursors.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/python/data-access-using-cursors.htm"&gt;Accessing data using cursors—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 03:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493897#M38746</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-03-10T03:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: I get invalid syntax</title>
      <link>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493898#M38747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Luke. That corrects the syntax problem. Now I get a new problem.&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "D:\Eric\Ejercicio\script\again.py", line 23, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue("test", row.getValue(field))&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\arcobjects\arcobjects.py", line 1096, in getValue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return convertArcObjectToPythonObject(self._arc_object.GetValue(*gp_fixargs(args)))&lt;/P&gt;&lt;P&gt;RuntimeError: ERROR 999999: Error executing function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to write in "test" field from insumo layer the value field from the select by location features loop of &lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;crbuff layer.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 15:41:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493898#M38747</guid>
      <dc:creator>G__EricCastillo_Morales</dc:creator>
      <dc:date>2016-03-10T15:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: I get invalid syntax</title>
      <link>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493899#M38748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to write in test field from some layer based on iterate feature selction. I get succes using model builder but I'm fail when I try with my own code.&lt;/P&gt;&lt;P&gt;The process with MB.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="mb.jpg" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/190627_mb.jpg" style="width: 620px; height: 606px;" /&gt;&lt;/P&gt;&lt;P&gt;The code and error.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="mycode.jpg" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/190634_mycode.jpg" style="width: 620px; height: 283px;" /&gt;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 16:12:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493899#M38748</guid>
      <dc:creator>G__EricCastillo_Morales</dc:creator>
      <dc:date>2016-03-10T16:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: I get invalid syntax</title>
      <link>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493900#M38749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I decided to put this in another question. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 16:28:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-get-invalid-syntax/m-p/493900#M38749</guid>
      <dc:creator>G__EricCastillo_Morales</dc:creator>
      <dc:date>2016-03-10T16:28:09Z</dc:date>
    </item>
  </channel>
</rss>

