<?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 Update cursor for Row updation in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/update-cursor-for-row-updation/m-p/436598#M34338</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i'm selecting a row and based on that row value i'm trying to update using update cursor for the "LAB field".&lt;BR /&gt;May be if condition is not working fine... Its not updated...&lt;BR /&gt;I dont know what is the error..Kindly suggest&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.MakeFeatureLayer_management("PT_10K","Ten_FL") &lt;BR /&gt;arcpy.MakeFeatureLayer_management("PT_50k","Fifty_FL")&lt;/P&gt;&lt;P&gt;with arcpy.da.SearchCursor("PT_50k", ["ORIG_FID"]) as cursor:&lt;BR /&gt; &lt;BR /&gt; i = 1&lt;BR /&gt; for row in cursor:&lt;BR /&gt; #print("Feature has x and y as of {1}{2}".format(row[1],row[2]))&lt;BR /&gt; arcpy.MakeFeatureLayer_management ("PT_50k","Layer")&lt;BR /&gt; arcpy.SelectLayerByAttribute_management("Layer","NEW_SELECTION",'"ORIG_FID" = {0}'.format(i))&lt;BR /&gt; arcpy.CopyFeatures_management("Layer","Fifty_FLY")&lt;BR /&gt; print i&lt;BR /&gt; i = i + 1&lt;BR /&gt; #arcpy.SelectLayerByLocation_management("Line_FL","WITHIN_A_DISTANCE","Trans_FL", "0.02 meters", "NEW_SELECTION")&lt;BR /&gt; arcpy.SelectLayerByLocation_management("Ten_FL","HAVE_THEIR_CENTER_IN","Fifty_FLY","14 meters","NEW_SELECTION")&lt;BR /&gt; &lt;BR /&gt; arcpy.CopyFeatures_management("Ten_FL","Ten_temp1")&lt;BR /&gt; fields = ['LAB','X','Y']&lt;BR /&gt; with arcpy.da.UpdateCursor('Ten_temp1',fields) as cursor1:&lt;BR /&gt; print "Cursor Assigned"&lt;BR /&gt; j = 1&lt;BR /&gt; for row in cursor1:&lt;BR /&gt; &lt;BR /&gt; x = row[1]&lt;BR /&gt; y = row[2]&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; if ((x == float(72.025000000129992)) and (y == float(35.77500392976323))):&lt;BR /&gt; row[0] = 'A'&lt;BR /&gt; print "row updated"&lt;BR /&gt; cursor1.updateRow(row)&lt;BR /&gt; elif x == 72.036 and y == 35.775:&lt;BR /&gt; row[0] = 'B'&lt;BR /&gt; print "row updated as B"&lt;BR /&gt; else:&lt;BR /&gt; print "not updated"&lt;BR /&gt; print j&lt;BR /&gt; j = j + 1&lt;BR /&gt; arcpy.Append_management("Ten_temp1","Ten_temp2","NO_TEST")&lt;BR /&gt; &lt;BR /&gt; arcpy.SelectLayerByAttribute_management ("Layer","CLEAR_SELECTION")&lt;BR /&gt; arcpy.SelectLayerByAttribute_management("Ten_FL","CLEAR_SELECTION")&lt;BR /&gt; print "Selected Rows Cleared"&lt;BR /&gt; arcpy.DeleteFeatures_management("Ten_temp1")&lt;BR /&gt; arcpy.Delete_management("Layer")&lt;BR /&gt; arcpy.Delete_management("Fifty_FLY")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Oct 2016 06:11:49 GMT</pubDate>
    <dc:creator>MANESK</dc:creator>
    <dc:date>2016-10-25T06:11:49Z</dc:date>
    <item>
      <title>Update cursor for Row updation</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-for-row-updation/m-p/436598#M34338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i'm selecting a row and based on that row value i'm trying to update using update cursor for the "LAB field".&lt;BR /&gt;May be if condition is not working fine... Its not updated...&lt;BR /&gt;I dont know what is the error..Kindly suggest&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.MakeFeatureLayer_management("PT_10K","Ten_FL") &lt;BR /&gt;arcpy.MakeFeatureLayer_management("PT_50k","Fifty_FL")&lt;/P&gt;&lt;P&gt;with arcpy.da.SearchCursor("PT_50k", ["ORIG_FID"]) as cursor:&lt;BR /&gt; &lt;BR /&gt; i = 1&lt;BR /&gt; for row in cursor:&lt;BR /&gt; #print("Feature has x and y as of {1}{2}".format(row[1],row[2]))&lt;BR /&gt; arcpy.MakeFeatureLayer_management ("PT_50k","Layer")&lt;BR /&gt; arcpy.SelectLayerByAttribute_management("Layer","NEW_SELECTION",'"ORIG_FID" = {0}'.format(i))&lt;BR /&gt; arcpy.CopyFeatures_management("Layer","Fifty_FLY")&lt;BR /&gt; print i&lt;BR /&gt; i = i + 1&lt;BR /&gt; #arcpy.SelectLayerByLocation_management("Line_FL","WITHIN_A_DISTANCE","Trans_FL", "0.02 meters", "NEW_SELECTION")&lt;BR /&gt; arcpy.SelectLayerByLocation_management("Ten_FL","HAVE_THEIR_CENTER_IN","Fifty_FLY","14 meters","NEW_SELECTION")&lt;BR /&gt; &lt;BR /&gt; arcpy.CopyFeatures_management("Ten_FL","Ten_temp1")&lt;BR /&gt; fields = ['LAB','X','Y']&lt;BR /&gt; with arcpy.da.UpdateCursor('Ten_temp1',fields) as cursor1:&lt;BR /&gt; print "Cursor Assigned"&lt;BR /&gt; j = 1&lt;BR /&gt; for row in cursor1:&lt;BR /&gt; &lt;BR /&gt; x = row[1]&lt;BR /&gt; y = row[2]&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; if ((x == float(72.025000000129992)) and (y == float(35.77500392976323))):&lt;BR /&gt; row[0] = 'A'&lt;BR /&gt; print "row updated"&lt;BR /&gt; cursor1.updateRow(row)&lt;BR /&gt; elif x == 72.036 and y == 35.775:&lt;BR /&gt; row[0] = 'B'&lt;BR /&gt; print "row updated as B"&lt;BR /&gt; else:&lt;BR /&gt; print "not updated"&lt;BR /&gt; print j&lt;BR /&gt; j = j + 1&lt;BR /&gt; arcpy.Append_management("Ten_temp1","Ten_temp2","NO_TEST")&lt;BR /&gt; &lt;BR /&gt; arcpy.SelectLayerByAttribute_management ("Layer","CLEAR_SELECTION")&lt;BR /&gt; arcpy.SelectLayerByAttribute_management("Ten_FL","CLEAR_SELECTION")&lt;BR /&gt; print "Selected Rows Cleared"&lt;BR /&gt; arcpy.DeleteFeatures_management("Ten_temp1")&lt;BR /&gt; arcpy.Delete_management("Layer")&lt;BR /&gt; arcpy.Delete_management("Fifty_FLY")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2016 06:11:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-for-row-updation/m-p/436598#M34338</guid>
      <dc:creator>MANESK</dc:creator>
      <dc:date>2016-10-25T06:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Update cursor for Row updation</title>
      <link>https://community.esri.com/t5/python-questions/update-cursor-for-row-updation/m-p/436599#M34339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could be the code formatting... however, you might want to fix it up so that errors can be assessed that aren't due to improper copy and paste&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2016 08:33:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-cursor-for-row-updation/m-p/436599#M34339</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-10-25T08:33:47Z</dc:date>
    </item>
  </channel>
</rss>

