<?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 Add Field decided to add an underscore to the field name in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584465#M45826</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I created a script to build a template geodatabase.&amp;nbsp; The code creates a geodatabase, adds a few domains, creates a feature class, adds some fields to the feature class and sets their domains, and finally sets all the default values for the fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is this one line of code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.AddField_management(NewTrees, "Public", "TEXT", "", "", "", "", "", "REQUIRED", "Public")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Somehow, this code creates a field called "Public_".&amp;nbsp; Note the added underscore.&amp;nbsp; (NewTrees is just a variable referencing the newly created feature class.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are no other fields in the feature class before this line (as it was just created).&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know why Python would add an underscore to a field name!?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Ben S.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Jun 2012 17:19:35 GMT</pubDate>
    <dc:creator>BenSloboda</dc:creator>
    <dc:date>2012-06-05T17:19:35Z</dc:date>
    <item>
      <title>Add Field decided to add an underscore to the field name</title>
      <link>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584465#M45826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I created a script to build a template geodatabase.&amp;nbsp; The code creates a geodatabase, adds a few domains, creates a feature class, adds some fields to the feature class and sets their domains, and finally sets all the default values for the fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is this one line of code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.AddField_management(NewTrees, "Public", "TEXT", "", "", "", "", "", "REQUIRED", "Public")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Somehow, this code creates a field called "Public_".&amp;nbsp; Note the added underscore.&amp;nbsp; (NewTrees is just a variable referencing the newly created feature class.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are no other fields in the feature class before this line (as it was just created).&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know why Python would add an underscore to a field name!?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Ben S.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 17:19:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584465#M45826</guid>
      <dc:creator>BenSloboda</dc:creator>
      <dc:date>2012-06-05T17:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Add Field decided to add an underscore to the field name</title>
      <link>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584466#M45827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Does anyone know why Python would add an underscore to a field name!?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you please do the 'Add Field' process manually with the tool itself from ArcToolbox and see whether you still get the field name with an underscore?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 17:28:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584466#M45827</guid>
      <dc:creator>NobbirAhmed</dc:creator>
      <dc:date>2012-06-05T17:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Add Field decided to add an underscore to the field name</title>
      <link>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584467#M45828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;By using the tool within ArcDesktop, the add field tool properly added a field named "Public" with no underscore.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following is the code snippet ArcDesktop used:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "UTC_Parcels"
arcpy.AddField_management("UTC_Parcels","Public","TEXT","#","#","#","#","NULLABLE","REQUIRED","#")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This doesn't answer why Python would put an underscore on the field name, however.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:07:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584467#M45828</guid>
      <dc:creator>BenSloboda</dc:creator>
      <dc:date>2021-12-12T01:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Add Field decided to add an underscore to the field name</title>
      <link>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584468#M45829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What type of geodatabase are you creating the feature class? "Public" is deemed as a reserved word in some different types. See this &lt;/SPAN&gt;&lt;A href="http://blogs.esri.com/esri/supportcenter/2010/05/26/words-by-reservation-only/"&gt;link&lt;/A&gt;&lt;SPAN&gt; for a full list of the reserved words for the different RDBMS.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 17:50:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584468#M45829</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2012-06-05T17:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Add Field decided to add an underscore to the field name</title>
      <link>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584469#M45830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does your code add an underscore if you name the field something else? 'Public' sounds like a keyword. Considering you're setting domains there might be some conflict there, but that's just speculation on my part.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 17:53:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584469#M45830</guid>
      <dc:creator>JohnCobb1</dc:creator>
      <dc:date>2012-06-05T17:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Add Field decided to add an underscore to the field name</title>
      <link>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584470#M45831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The word "Public" does appear on the&amp;nbsp; ISO/ANSI SQL99 reserved words and the T-SQL reserved words list, but that doesn't really explain to me why Python changed it or why running the tool from within ArcDesktop worked fine...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using an Enterprise SDE v.10 on SQL 2008 R2. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Ben S.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 18:53:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584470#M45831</guid>
      <dc:creator>BenSloboda</dc:creator>
      <dc:date>2012-06-05T18:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Add Field decided to add an underscore to the field name</title>
      <link>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584471#M45832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When you add a field with a reserved name by code or through the tool, it automatically adds an underscore to it. In your desktop test, were you adding that field to a feature class stored in that particular geodatabase?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 19:05:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584471#M45832</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2012-06-05T19:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Add Field decided to add an underscore to the field name</title>
      <link>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584472#M45833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No, my mistake.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]14959[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once I attempted on the same database, the identical results were evident.&amp;nbsp; So it looks like the RBDMS is to blame.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Interesting turn of events, and I'd like to thank everyone for helping figure out what happened!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Ben S.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 19:24:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584472#M45833</guid>
      <dc:creator>BenSloboda</dc:creator>
      <dc:date>2012-06-05T19:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Add Field decided to add an underscore to the field name</title>
      <link>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584473#M45834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Glad to help. Please mark the thread as answered.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jun 2012 12:07:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-field-decided-to-add-an-underscore-to-the/m-p/584473#M45834</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2012-06-06T12:07:07Z</dc:date>
    </item>
  </channel>
</rss>

