<?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: Strange behavior of getValue (field_name) method for Row object in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266363#M20495</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, well, looks like things are a little different at 10.1 and maybe it has something to do with a difference in the da module search cursor?&amp;nbsp; I am not using 10.1 yet, but trying to be more familiar before switching over.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, if you are trying to get at the OBJECTID, it looks like for a file gdb---&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;--- set up the cursor as such:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;with arcpy.da.SearchCursor(fc, ("OID@")) as cursor:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;--- of course get at the 'row' object as in "for row in cursor", then print the OID as such:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print("Current OID is {0}".format(row[0]))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if that works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&amp;nbsp; Looks like the OID@ token should work for any feature or table format supporting an Object ID field.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Oct 2012 15:47:51 GMT</pubDate>
    <dc:creator>T__WayneWhitley</dc:creator>
    <dc:date>2012-10-15T15:47:51Z</dc:date>
    <item>
      <title>Strange behavior of getValue (field_name) method for Row object</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266357#M20489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;I just wanted to check if I am the only one experiencing this problem or might be making a mistake in the usage of Row object 'getValue(field_name)' method. I believe this method was working fine with ArcGIS 10 release but it is throwing error in 10.1. I tried to go through the documentation at '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018z0000008r000000" rel="nofollow" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//018z0000008r000000&lt;/A&gt;&lt;SPAN&gt;' but it seems that code sample at same page never uses this method instead is using 'row.FIELD_NAME'. The row.FIELD_NAME method works fine but it is kind of hardcoding the field name which no one would like. Please comment or suggest if you have a solution to this problem. Here is the code snippet which throws an error. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cur = arcpy.SearchCursor(inputFC)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row = cur.Next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while row:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(row.getValue(field_name)) # if I just replace this line with 'print(row.FIELD_NAME) then it works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cur.Next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;del cur&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance for your time and support.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Oct 2012 11:44:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266357#M20489</guid>
      <dc:creator>MohammadIshfaq</dc:creator>
      <dc:date>2012-10-14T11:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of getValue (field_name) method for Row object</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266358#M20490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I believe you have to quote the field - for example if you actually have a field by the name, fieldname:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row.getValue("fieldname")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(unless of course fieldname is a variable representing text, as in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fieldname = "fieldname"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Oct 2012 12:13:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266358#M20490</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-10-14T12:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of getValue (field_name) method for Row object</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266359#M20491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I believe you have to quote the field - for example if you actually have a field by the name, fieldname:&lt;BR /&gt;row.getValue("fieldname")&lt;BR /&gt;&lt;BR /&gt;(unless of course fieldname is a variable representing text, as in:&lt;BR /&gt;fieldname = "fieldname"&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&amp;nbsp; Also, I question (1) your use of the print statement and (2) if you have to convert the return value to string.&amp;nbsp; Such as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print str(row.getValue("fieldname"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I thought it an interesting additional note that some py functions return strings and may need to be converted to be useful -- e.g., apparently returning results on getCount is string and in the following sample online it is made an integer for further use (a little counterintuitive):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(see section Getting results from a tool)&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000000n000000"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000000n000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Oct 2012 12:41:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266359#M20491</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-10-14T12:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of getValue (field_name) method for Row object</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266360#M20492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;EDIT:&amp;nbsp; Also, I question (1) your use of the print statement and (2) if you have to convert the return value to string.&amp;nbsp; Such as:&lt;BR /&gt;&lt;BR /&gt;print str(row.getValue("fieldname"))&lt;BR /&gt;&lt;BR /&gt;I thought it an interesting additional note that some py functions return strings and may need to be converted to be useful -- e.g., apparently returning results on getCount is string and in the following sample online it is made an integer for further use (a little counterintuitive):&lt;BR /&gt;&lt;BR /&gt;(see section Getting results from a tool)&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000000n000000"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000000n000000&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oops, should have said getCount returns an object that is converted to string w/ getOutput and in the sample, the necessary part of the string (which is the count only), is converted to integer.&amp;nbsp; Sorry for any confusion.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Oct 2012 12:59:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266360#M20492</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-10-14T12:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of getValue (field_name) method for Row object</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266361#M20493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Oops, should have said getCount returns an object that is converted to string w/ getOutput and in the sample, the necessary part of the string (which is the count only), is converted to integer.&amp;nbsp; Sorry for any confusion.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Wayne_Whitley for your informative answers. However, none of these suggestions worked for me. It is a bit strange as they changed the searching api a bit and now we have to code something like this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fields = ["OBJECTID","AREA_ID"]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(sourceObjectFilePathName, fields) as cursor:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&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; print("{0},{1}".format(row[0], row[1])&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; del cursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;except Exception as e:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print e.message&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Though, strange enough for me, I can't get the value of 'GLOBALID' field in a feature class as following exception is thrown when I add it to the search criteria. I wonder way and it is kind of really frustrating. I need it as it is the permanent unique key that I can use to compare features from one feature class to another.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;unsupported field type GLOBALID #11&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Exception Type is: &amp;lt;class 'Queue.Empty'&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;************************************&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2012 04:05:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266361#M20493</guid>
      <dc:creator>MohammadIshfaq</dc:creator>
      <dc:date>2012-10-15T04:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of getValue (field_name) method for Row object</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266362#M20494</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;BR /&gt;&lt;SPAN&gt;Have you tried using a for loop to retrieve the Global ID values? The following worked for me:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[HTML]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SC = arcpy.SearchCursor(r'C:\Data\TestData.gdb\Roads')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;field_name = 'GlobalID'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in SC:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.getValue(field_name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del row, SC&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[/HTML]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2012 15:14:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266362#M20494</guid>
      <dc:creator>JillianPenney</dc:creator>
      <dc:date>2012-10-15T15:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of getValue (field_name) method for Row object</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266363#M20495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, well, looks like things are a little different at 10.1 and maybe it has something to do with a difference in the da module search cursor?&amp;nbsp; I am not using 10.1 yet, but trying to be more familiar before switching over.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, if you are trying to get at the OBJECTID, it looks like for a file gdb---&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;--- set up the cursor as such:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;with arcpy.da.SearchCursor(fc, ("OID@")) as cursor:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;--- of course get at the 'row' object as in "for row in cursor", then print the OID as such:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print("Current OID is {0}".format(row[0]))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if that works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&amp;nbsp; Looks like the OID@ token should work for any feature or table format supporting an Object ID field.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2012 15:47:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266363#M20495</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-10-15T15:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of getValue (field_name) method for Row object</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266364#M20496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Wayne Whitley and JillPenney for your help. The problem is resolved with the Jill suggestion.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my second reply I already have mentioned that I can retrieve objectID values but it won't serve my purpose because ObjectIDs are changed when ever Geodatabase administrator compresses the database and hence they are not unique.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The for loop trick somehow worked and I could retrieve the GLOBALID information as well. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once again thanks everyone for your support and time.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2012 08:47:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266364#M20496</guid>
      <dc:creator>MohammadIshfaq</dc:creator>
      <dc:date>2012-10-16T08:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behavior of getValue (field_name) method for Row object</title>
      <link>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266365#M20497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, interesting, apparently there are 2 'versions' of the searchcursor with 10.1 -- I am not at 10.1 yet, but would be interested to know if this would work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;with arcpy.da.SearchCursor(fc, ("GLOBALID@")) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Current GLOBALID is {0}".format(row[0]))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:04:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/strange-behavior-of-getvalue-field-name-method-for/m-p/266365#M20497</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-11T13:04:51Z</dc:date>
    </item>
  </channel>
</rss>

