<?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 Check table value and featureclass name in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/check-table-value-and-featureclass-name/m-p/1008678#M59250</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;i want to make a model, with model builder from arcmap. but i must make a script for my step;&lt;/P&gt;&lt;P&gt;i have a table and a feature class(inputdata). there are fields, named "FEATURENAME" and "FIELDNAME"&amp;nbsp; field. i want to check both my table's "FEATURENAMES" and my featureclass's own name then if they equal gave me "exist" value, if they arent equal, it gives me "no exist" value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;and after this step, "exist" value i will add (matched) row's "FIELDNAME" field in my featureclass with my model. (i will make this step with "AddField" tool.&lt;/P&gt;&lt;P&gt;Thnks a lot for your ans.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Dec 2020 21:15:05 GMT</pubDate>
    <dc:creator>yalcinsahin</dc:creator>
    <dc:date>2020-12-10T21:15:05Z</dc:date>
    <item>
      <title>Check table value and featureclass name</title>
      <link>https://community.esri.com/t5/python-questions/check-table-value-and-featureclass-name/m-p/1008678#M59250</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;i want to make a model, with model builder from arcmap. but i must make a script for my step;&lt;/P&gt;&lt;P&gt;i have a table and a feature class(inputdata). there are fields, named "FEATURENAME" and "FIELDNAME"&amp;nbsp; field. i want to check both my table's "FEATURENAMES" and my featureclass's own name then if they equal gave me "exist" value, if they arent equal, it gives me "no exist" value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;and after this step, "exist" value i will add (matched) row's "FIELDNAME" field in my featureclass with my model. (i will make this step with "AddField" tool.&lt;/P&gt;&lt;P&gt;Thnks a lot for your ans.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 21:15:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/check-table-value-and-featureclass-name/m-p/1008678#M59250</guid>
      <dc:creator>yalcinsahin</dc:creator>
      <dc:date>2020-12-10T21:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Check table value and featureclass name</title>
      <link>https://community.esri.com/t5/python-questions/check-table-value-and-featureclass-name/m-p/1008689#M59252</link>
      <description>&lt;P&gt;Have a look at&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/data-access/searchcursor-class.htm" target="_blank"&gt;SearchCursor—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 21:30:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/check-table-value-and-featureclass-name/m-p/1008689#M59252</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-12-10T21:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: Check table value and featureclass name</title>
      <link>https://community.esri.com/t5/python-questions/check-table-value-and-featureclass-name/m-p/1010336#M59302</link>
      <description>&lt;P&gt;If I understand your project goal correctly, that you want to see if a feature class' name is in a data table, and if so, return the associated field name for that table, then the following script may serve as a starting point.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

fc = arcpy.GetParameter(0)   # input feature class : feature layer, input
tbl = arcpy.GetParameter(1)  # input data table: table, input
# FieldName : Parameter(2)   # derived, output, string

fc_desc = arcpy.Describe(fc)
arcpy.AddMessage("Feature type: {}".format(fc_desc.dataType)) # 'FeatureClass','FeatureLayer'
arcpy.AddMessage("Feature name: {}".format(fc_desc.name))
arcpy.AddMessage("Feature catalog path: {}".format(fc_desc.catalogPath))

tbl_desc = arcpy.Describe(tbl)
arcpy.AddMessage("Table type: {}".format(tbl_desc.dataType)) # 'Table'
arcpy.AddMessage("Table name: {}".format(tbl_desc.name))
arcpy.AddMessage("Table catalog path: {}".format(tbl_desc.catalogPath))

# may wish to validate that table has fields 'FEATURENAME' and 'FIELDNAME'

where = "FEATURENAME = '{}'".format(fc_desc.name)
arcpy.AddMessage("Where clause: {}".format(where))

cursor = arcpy.da.SearchCursor(tbl_desc.catalogPath,['FIELDNAME'], where)
if any(cursor):
    fieldname = cursor[0]
else:
    fieldname = '' # empty string

del cursor
arcpy.SetParameterAsText(2, fieldname)
    
arcpy.AddMessage("Fieldname: {}".format(fieldname if len(fieldname) else '* FIELD NOT FOUND *'))&lt;/LI-CODE&gt;&lt;P&gt;The script uses a number of AddMessage lines for debugging.&amp;nbsp; It does provide an idea for the&amp;nbsp; general flow.&lt;/P&gt;&lt;P&gt;In actual use, I would probably have most of the work done in the ToolValidator section where the parameters can be checked more thoroughly before the script tool completes.&amp;nbsp; One check the validator would make is to verify that the data table has the proper fields.&amp;nbsp; Another check could determine that the feature's name is in the data table.&lt;/P&gt;&lt;P&gt;If you plan to add a field to the feature, the tool could also be set to verify that the feature does not already contain the field.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2020 20:58:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/check-table-value-and-featureclass-name/m-p/1010336#M59302</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2020-12-16T20:58:01Z</dc:date>
    </item>
  </channel>
</rss>

