<?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: gp.calculatefield_management -- seemingly erratic behaviour in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/gp-calculatefield-management-seemingly-erratic/m-p/733448#M24176</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think I once I applied sp1 for 9.3.1 it worked.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 May 2011 02:04:37 GMT</pubDate>
    <dc:creator>justinperez</dc:creator>
    <dc:date>2011-05-26T02:04:37Z</dc:date>
    <item>
      <title>gp.calculatefield_management -- seemingly erratic behaviour</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/gp-calculatefield-management-seemingly-erratic/m-p/733444#M24172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am using a few search cursors and deleting them as I go.&amp;nbsp; gp.calculatefield_management is behaving erratic from what I see.&amp;nbsp; The gp.calculatefield_management is working but is not hitting my print statements and then not hitting the code further downstream.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I first had the gp.calculatefield_management working against a shapefile that was clipped during the initial search cursor.&amp;nbsp; So the calculate method was being called against a newly created shapefile.&amp;nbsp; I thought that maybe the searchcursor didn't like the calculate method.&amp;nbsp; When I commented out the calculate calls everything worked fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I would make sure to clean up any objects and then it would work once.&amp;nbsp; Then nothing.&amp;nbsp; It wasn't hitting my print statements.&amp;nbsp; I use the gp.calculatefield_management in many other geoprocessing python scripts and never this behaviour.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Apr 2010 20:08:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/gp-calculatefield-management-seemingly-erratic/m-p/733444#M24172</guid>
      <dc:creator>justinperez</dc:creator>
      <dc:date>2010-04-20T20:08:38Z</dc:date>
    </item>
    <item>
      <title>Shooting yourself in the foot!</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/gp-calculatefield-management-seemingly-erratic/m-p/733445#M24173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think I can guess what is happening.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You will get into trouble deleting records while looping through the same set.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The only way to make this safe to delete records is to make a copy of the keys or the full set and use that in the loop.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Apr 2010 23:35:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/gp-calculatefield-management-seemingly-erratic/m-p/733445#M24173</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2010-04-29T23:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: gp.calculatefield_management -- seemingly erratic behaviour</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/gp-calculatefield-management-seemingly-erratic/m-p/733446#M24174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To start I will say I used the update cursor and some dicts to hold values to be used in the update cursor to solve the problem... Problem solved with different approach!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would, however, like to understand what went wrong in this code below.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did a select by location on a polygon layer to clip a polyline layer.&amp;nbsp; I wanted to move attributes from the polygon layer to the subsequent clipped polyline layers.&amp;nbsp; I figured that a search cursor on the polygon layer for each row as I do the clip would let me call a calculatefield on the polyline clipped layers for each loop of the search cursor of the polygon layer.&amp;nbsp; It would work sometimes and sometimes not but would never hit my print statements (maybe once it did).&amp;nbsp; When I commented out the calculatefield calls and let the overall code run all my print statements would get hit.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My thought was that calling a calculatefield inside of a search cursor loop (even if the calculate field was not being done against the layer that the search cursor was working on but instead against the newly created clipped layer).&amp;nbsp; As I said, it would give me results sometimes and sometimes not.&amp;nbsp; Maybe this will help some else.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the broken code...let me know if anyone wants to see the update cursor and dicts code that worked..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.makefeaturelayer(r"path\to\school.shp", "schl")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.selectlayerbylocation("schl", "intersect", r"path\to\layer to clip")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;scur = gp.searchcursor("schl")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row1 = scur.reset()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row1 = scur.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while row1:&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; v = str(random.randint(1, 100000))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name1 = row1.name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print name1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat1 = row1.shape&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print feat1.area&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.clip_analysis(twline, feat1, wkschool + "\\" + v)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.addfield_management(wkschool + "\\" + v + ".shp", "ISDName", "text", "#", "#", "100")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.calculatefield_management(wkschool + "\\" + v + ".shp", "ISDName", "str(name1)" , "Python_9.3")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row1 = scur.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del scur&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Apr 2010 13:08:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/gp-calculatefield-management-seemingly-erratic/m-p/733446#M24174</guid>
      <dc:creator>justinperez</dc:creator>
      <dc:date>2010-04-30T13:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: gp.calculatefield_management -- seemingly erratic behaviour</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/gp-calculatefield-management-seemingly-erratic/m-p/733447#M24175</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;Did you get this to work eventually?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If so, could you post the code?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Kent&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Aug 2010 03:52:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/gp-calculatefield-management-seemingly-erratic/m-p/733447#M24175</guid>
      <dc:creator>KentBurley</dc:creator>
      <dc:date>2010-08-26T03:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: gp.calculatefield_management -- seemingly erratic behaviour</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/gp-calculatefield-management-seemingly-erratic/m-p/733448#M24176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think I once I applied sp1 for 9.3.1 it worked.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 May 2011 02:04:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/gp-calculatefield-management-seemingly-erratic/m-p/733448#M24176</guid>
      <dc:creator>justinperez</dc:creator>
      <dc:date>2011-05-26T02:04:37Z</dc:date>
    </item>
  </channel>
</rss>

