<?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 help for row.SetValue() function in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39575#M1402</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for that, I was looking where I could find docs for those methods.&lt;/P&gt;&lt;P&gt;They are methods of the row object:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/classes/row.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/classes/row.htm"&gt;Row—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 23 Aug 2020 21:53:49 GMT</pubDate>
    <dc:creator>AndresCastillo</dc:creator>
    <dc:date>2020-08-23T21:53:49Z</dc:date>
    <item>
      <title>Python script help for row.SetValue() function</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39566#M1393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am creating a python script and have a question about the row.SetValue() function. I have read in a table and a feature class along with a string value that represents one of the fields in the feature class. I join the table to the feature class and perform some calculations. Based on the result from those calculations, I then need to set the value of the of the field denoted by the string value. I am not sure what the proper code (if this is even possible) to do this. Here is what I have tried.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First, I tried to set the 'SchoolLevel' field to a value:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]row.SetValue(SchoolLevel, M[0][1])[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am pretty sure that this doesn't work because there is a join.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, then I tried to add in the name of the feature class to the code as such:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]row.SetValue(Scenario_Template_1011.SchoolLevel, M[0][1])[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This didn't work, so then I tried to put the feature class name in quotes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]row.SetValue("Scenario_Template_1011."SchoolLevel, M[0][1][/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This throws me an invalid syntax error before I can even run the script. This makes sens, but I am not sure how to correctly code this up.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically, Scenario_Template_1011 is the name of the feature class that is joined by another table and SchoolLevel is a variable representing a field in Scenario_Template_1011. I am trying to set the value of that field using a cell in a matrix that I created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance for any help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Sep 2010 15:24:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39566#M1393</guid>
      <dc:creator>deleted-user-rQoEFM5qzbHE</dc:creator>
      <dc:date>2010-09-16T15:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Python script help for row.SetValue() function</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39567#M1394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Don't know much about Python or how joins work, but can you adjust the UpdateCursor to include fewer fields (4th item in argument)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise, next thing I would try would be a combination of the SearchCursor and UpdateCursor, though I don't know how these run concurrently.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Sep 2010 19:06:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39567#M1394</guid>
      <dc:creator>RussellKallstrom</dc:creator>
      <dc:date>2010-09-16T19:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python script help for row.SetValue() function</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39568#M1395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What are M[0][1]?&amp;nbsp; are these values from a python list? if so try,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;row.SetValue(SchoolLevel, M[0] + M[1])&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Sep 2010 19:42:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39568#M1395</guid>
      <dc:creator>JeffLee</dc:creator>
      <dc:date>2010-09-16T19:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python script help for row.SetValue() function</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39569#M1396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the responses. I think I know what my issue is but I have run into other problems and have to fix those before I know for sure. Ah, the joys of coding :).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Snoop, M is an nxm matrix. In the example I am accessing the value of the cell in the first column, second row.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Sep 2010 13:41:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39569#M1396</guid>
      <dc:creator>deleted-user-rQoEFM5qzbHE</dc:creator>
      <dc:date>2010-09-17T13:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Python script help for row.SetValue() function</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39570#M1397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have been unable to figure out why this is not working. Here is the code in the hopes that someone will be able to see where I am going wrong.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = gp.UpdateCursor(inTable)
row = rows.next()

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; while row:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in range(0,numSchools):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; school&lt;I&gt; = row.GetValue(Elem&lt;I&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M&lt;I&gt;[1] = school&lt;I&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M.sort(lambda x, y: cmp(x[1], y[1]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M.reverse()

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if M[0][1] &amp;gt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; school = M[0][0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.SetValue("[ScenarioTemplate_1011." + String + "]", school)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("You made it through the if statement")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.UpdateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.next()

except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddError("Failed to set the value of new scenario field to new school assignment")&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:32:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39570#M1397</guid>
      <dc:creator>deleted-user-rQoEFM5qzbHE</dc:creator>
      <dc:date>2021-12-10T21:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python script help for row.SetValue() function</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39571#M1398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hello there , &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i guess i have similar problem would appreciate if you have any idea. i want to copy the records of a single row and dublicate it in the same attribute table uisng python script that is first getvalue and then setvalue. i tired first to insert a new row then , put the value of the row to be copied in a list[] and then try to set the values of the new row from the list , but it did not work. any idea ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...............................................&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = gp.UpdateCursor(fc)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cur = gp.searchcursor(fc)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row = cur.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i = 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while row:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.Urban ==22:&amp;nbsp;&amp;nbsp; # this is just to check if it is the right row &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fields = gp.Listfields(fc)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field = fields.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = i&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while field:&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; value = Store&lt;I&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # store is the collection of records from the row to be copied &lt;/I&gt;&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.setvalue("(field.name)", value)&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; #rows.UpdateRow(row)&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; i+=1&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; field = fields.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del field&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.UpdateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cur.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del rows&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.................................................... &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanx&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jan 2012 06:56:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39571#M1398</guid>
      <dc:creator>BiniamTes</dc:creator>
      <dc:date>2012-01-23T06:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Python script help for row.SetValue() function</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39572#M1399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;to biniamts;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You cannot add a row with an Update Cursor. Only InsertCursor has a new row method.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try running your search cursor first, and building either a nested list (if the existing records are in the order you would like to write them) OR building a dictionary (if you want to reference the records by a unique key value). Run an InsertCursor from whichever you built to add the new duplicated records.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jan 2012 13:31:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39572#M1399</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2012-01-23T13:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python script help for row.SetValue() function</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39573#M1400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Also be sure to check your casing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the methods for Getting and Setting Values are:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;getValue(field_name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;setValue(field_name, object)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;--Took this straight for ArcGIS help&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Some of the posts in this thread had the wrong casing (e.g. 'SetValue')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-George&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jan 2012 15:20:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39573#M1400</guid>
      <dc:creator>GeorgeNewbury</dc:creator>
      <dc:date>2012-01-25T15:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Python script help for row.SetValue() function</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39574#M1401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, that is a real concern with Arc10. Arc9 was indifferent to capitalization on geoprocessor comands, but Arcpy is a stickler.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jan 2012 16:31:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39574#M1401</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2012-01-25T16:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python script help for row.SetValue() function</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39575#M1402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for that, I was looking where I could find docs for those methods.&lt;/P&gt;&lt;P&gt;They are methods of the row object:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/classes/row.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/classes/row.htm"&gt;Row—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Aug 2020 21:53:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-help-for-row-setvalue-function/m-p/39575#M1402</guid>
      <dc:creator>AndresCastillo</dc:creator>
      <dc:date>2020-08-23T21:53:49Z</dc:date>
    </item>
  </channel>
</rss>

