<?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: Get Field Value in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/get-field-value/m-p/456749#M35898</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see you started a new question, which I would have suggested too.&amp;nbsp; For others...&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/180514"&gt;Compare value from n and n+1 row in searchCursor&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Jul 2016 15:15:32 GMT</pubDate>
    <dc:creator>RebeccaStrauch__GISP</dc:creator>
    <dc:date>2016-07-27T15:15:32Z</dc:date>
    <item>
      <title>Get Field Value</title>
      <link>https://community.esri.com/t5/python-questions/get-field-value/m-p/456741#M35890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Im trying to find/write a simple code line that will get the value from a &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;specific row and columm (field name). - I only have one table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I cant use the modelbuilder tool (GetFieldValue) because i need it in python..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thx!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jul 2012 08:04:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-field-value/m-p/456741#M35890</guid>
      <dc:creator>yanaybrook1</dc:creator>
      <dc:date>2012-07-25T08:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Get Field Value</title>
      <link>https://community.esri.com/t5/python-questions/get-field-value/m-p/456742#M35891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Look into Search Cursors (arcpy.SearchCursor or the new arcpy.da.SearchCursor if you're at 10.1).&amp;nbsp; These allow you to create an object containing the rows of a given table (spatial or otherwise) and step through that object row by row.&amp;nbsp; If you have a specific row or set of values in a feature class you can create a search cursor based on a sql query.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, if you had a feature class with a classification of things in a field named 'class' and you needed to extract all the values held in a field named 'Data' for records with a class = 1 you might do something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;things = arcpy.SearchCursor(yourFeatureClass, """ 'class' = "1" """,'','Data')
for thing in things:
&amp;nbsp;&amp;nbsp; mydata = thing.Data
&amp;nbsp;&amp;nbsp; ...code to do something with the mydata value, such as writing it to a text file, etc.. &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There may be other ways to approach this if you're looking for one value from a single row, but usually we want to deal with many rows in the same way, perhaps conditionally based on the the value held in a field.&amp;nbsp; Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:20:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-field-value/m-p/456742#M35891</guid>
      <dc:creator>ChristopherThompson</dc:creator>
      <dc:date>2021-12-11T20:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Get Field Value</title>
      <link>https://community.esri.com/t5/python-questions/get-field-value/m-p/456743#M35892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi There&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to read a value from one column (result of calculate UTM tool) and it is same for all the points (most likely there will be only one point). I can use searchcursor in arcpy. But is there any simple way similar to GetFieldValue for arcpy?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2012 16:58:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-field-value/m-p/456743#M35892</guid>
      <dc:creator>DeeptiPuri</dc:creator>
      <dc:date>2012-10-18T16:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Get Field Value</title>
      <link>https://community.esri.com/t5/python-questions/get-field-value/m-p/456744#M35893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This sample code may help if you want all the values in a column, or if you want a specific value using getValue in a search cursor.&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 = 'Object ID'&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; # if you want all values in the field&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;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # you can also get specific values&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.getValue(field_name) == 5&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = row.getValue(field_name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # using break allows you to stop the search cursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;del row, SC &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print x&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[/HTML]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2012 23:01:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-field-value/m-p/456744#M35893</guid>
      <dc:creator>JillianPenney</dc:creator>
      <dc:date>2012-10-18T23:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Get Field Value</title>
      <link>https://community.esri.com/t5/python-questions/get-field-value/m-p/456745#M35894</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;I am having this issue that the row.getValue(field.name) breaks my script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.SearchCursor(DBase_file)&amp;nbsp;&amp;nbsp;&amp;nbsp; 
for row in rows: 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in desc.fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rVal = row.getValue(field.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Field Name: " + field.Name + "Value: " + rVal)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the examples above you have a haed coded field name but I am looping through unknown field names and it just stops at the rVal=... line.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas??&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:20:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-field-value/m-p/456745#M35894</guid>
      <dc:creator>RobertPotter</dc:creator>
      <dc:date>2021-12-11T20:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Get Field Value</title>
      <link>https://community.esri.com/t5/python-questions/get-field-value/m-p/456746#M35895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I question your use of desc.fields...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Not sure that describe object is iterable.&amp;nbsp; Can't you use the listFields function instead?&amp;nbsp; Careful with case, could be ListFields, look up the topic of listing data.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 07:11:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-field-value/m-p/456746#M35895</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-05-17T07:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Get Field Value</title>
      <link>https://community.esri.com/t5/python-questions/get-field-value/m-p/456747#M35896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I question your use of desc.fields...&lt;BR /&gt;Not sure that describe object is iterable.&amp;nbsp; Can't you use the listFields function instead?&amp;nbsp; Careful with case, could be ListFields, look up the topic of listing data.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As Wayne told, use&amp;nbsp; arcpy.ListFields instead of desc.fields, also you should change AddMessage statement a bit, to make sure it won't crush if field type is different than TEXT:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
fields = arcpy.ListFields(DBase_file)
rows = arcpy.SearchCursor(DBase_file)&amp;nbsp;&amp;nbsp;&amp;nbsp; 
for row in rows: 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rVal = row.getValue(field)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Field Name: " + field + "Value: " + str(rVal)) # is not always string
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Arek&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:20:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-field-value/m-p/456747#M35896</guid>
      <dc:creator>ArkadiuszMatoszka</dc:creator>
      <dc:date>2021-12-11T20:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Get Field Value</title>
      <link>https://community.esri.com/t5/python-questions/get-field-value/m-p/456748#M35897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a similar problem. I have a searchCursor that goes through a specific column in a table. On every row I need to compare the value from this row with the value on the next row and if they are equal do something and if they aren't equal do something else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")
table = arcpy.mapping.ListTableViews(mxd)[0]
column = "name"
cursor=arcpy.SearchCursor(table)
for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(row.getValue(column))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have this sample of code. It goes through all rows. But how can I compare the value from row[row] with the value from row[row+1]?? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:20:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-field-value/m-p/456748#M35897</guid>
      <dc:creator>ZdeněkSoldán</dc:creator>
      <dc:date>2021-12-11T20:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Get Field Value</title>
      <link>https://community.esri.com/t5/python-questions/get-field-value/m-p/456749#M35898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see you started a new question, which I would have suggested too.&amp;nbsp; For others...&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/180514"&gt;Compare value from n and n+1 row in searchCursor&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jul 2016 15:15:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-field-value/m-p/456749#M35898</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-07-27T15:15:32Z</dc:date>
    </item>
  </channel>
</rss>

