<?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 Field type in Python. Please help in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/field-type-in-python-please-help/m-p/465748#M15646</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;trying to build a model using a combination of model builder and python. I'm not a programmer so my preference is just model builder but I can't do a certain step without a python script (at least I can't think of a way).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a shapefile and I need to test whether or not it has a specific field name (I found a code for that in the ESRI help files) and also if it does have that field that it is of a particular type and length e.g. text and 15.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The ESRI script works fine for determining the presence of the field. I can't get the code adjusted to allow for the field type though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code allows for 2 outputs, essentially True or False, which i can use as preconditions for the rest of the model.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If anyone has a hint on how to alter this so that I can test whether the field is of the correct type and length that would be much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Sep 2010 12:23:15 GMT</pubDate>
    <dc:creator>RickyCraig</dc:creator>
    <dc:date>2010-09-30T12:23:15Z</dc:date>
    <item>
      <title>Field type in Python. Please help</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-type-in-python-please-help/m-p/465748#M15646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;trying to build a model using a combination of model builder and python. I'm not a programmer so my preference is just model builder but I can't do a certain step without a python script (at least I can't think of a way).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a shapefile and I need to test whether or not it has a specific field name (I found a code for that in the ESRI help files) and also if it does have that field that it is of a particular type and length e.g. text and 15.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The ESRI script works fine for determining the presence of the field. I can't get the code adjusted to allow for the field type though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code allows for 2 outputs, essentially True or False, which i can use as preconditions for the rest of the model.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If anyone has a hint on how to alter this so that I can test whether the field is of the correct type and length that would be much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Sep 2010 12:23:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-type-in-python-please-help/m-p/465748#M15646</guid>
      <dc:creator>RickyCraig</dc:creator>
      <dc:date>2010-09-30T12:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: Field type in Python. Please help</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-type-in-python-please-help/m-p/465749#M15647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could do something like this to test the TYPE and LENGTH, simply using an "if" statement:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;loop = gp.listFields(In_Table, "*", "ALL")
field = loop.next()
while field:
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # List the name, length and type of every field in the shapefile
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Name:&amp;nbsp;&amp;nbsp; " + field.Name
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Length: " + str(field.Length)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Type:&amp;nbsp;&amp;nbsp; " + field.Type+"\n"


&amp;nbsp;&amp;nbsp;&amp;nbsp; if field.name == "PlanzNr" and field.length == 20 and field.type == "TEXT":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...do something...&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:40:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-type-in-python-please-help/m-p/465749#M15647</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2021-12-11T20:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Field type in Python. Please help</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-type-in-python-please-help/m-p/465750#M15648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;FYI,&amp;nbsp; using the ListFields method with a feature class in a file geodatabase returns a field type of "string" not "text".&amp;nbsp; I'm not sure if this is different for shapefiles.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However if you are creating a new field in a feature class in a file geodatabase using the AddField method a type of "text" is required.&amp;nbsp; I'm not sure if this is different for shapefiles.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is not the only difference.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A couple others are:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ListFields returns: Integer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AddField needs:&amp;nbsp;&amp;nbsp;&amp;nbsp; Long&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;List fields returns: SmallInteger&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Addfield needs:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Short&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Joel&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Sep 2010 20:18:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-type-in-python-please-help/m-p/465750#M15648</guid>
      <dc:creator>JoelCalhoun</dc:creator>
      <dc:date>2010-09-30T20:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Field type in Python. Please help</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/field-type-in-python-please-help/m-p/465751#M15649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey guys,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for the replies. I'll try your suggestions and see how far I get.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Oct 2010 08:07:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/field-type-in-python-please-help/m-p/465751#M15649</guid>
      <dc:creator>RickyCraig</dc:creator>
      <dc:date>2010-10-01T08:07:54Z</dc:date>
    </item>
  </channel>
</rss>

