<?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: ValidateTableName inconsistent in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/validatetablename-inconsistent/m-p/1573143#M73474</link>
    <description>&lt;P&gt;I have reported a similar &lt;A href="https://support.esri.com/en-us/bug/running-the-arcpyvalidatetablenametnws-within-notebooks-bug-000166329" target="_self"&gt;bug&lt;/A&gt;&amp;nbsp;in 2024 which has yet to be resolved. Clearly the function is buggy and needs ESRI to resolve it.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jan 2025 15:27:20 GMT</pubDate>
    <dc:creator>DuncanHornby</dc:creator>
    <dc:date>2025-01-07T15:27:20Z</dc:date>
    <item>
      <title>ValidateTableName inconsistent</title>
      <link>https://community.esri.com/t5/python-questions/validatetablename-inconsistent/m-p/1573081#M73473</link>
      <description>&lt;P&gt;Why does &lt;EM&gt;arcpy.ValidateTableName&lt;/EM&gt; not replace hyphens (-) when used in a script outside Arc GIS Pro?&lt;BR /&gt;&lt;BR /&gt;From inside Arc GIS Pro&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MortenBackNielsen_1-1736257416748.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/122828i5838F4E36C082928/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MortenBackNielsen_1-1736257416748.png" alt="MortenBackNielsen_1-1736257416748.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from script but with the ArcGIS Pro python interpreter&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MortenBackNielsen_0-1736257382235.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/122827i278529B5A8A19E30/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MortenBackNielsen_0-1736257382235.png" alt="MortenBackNielsen_0-1736257382235.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Note in Arcgis Pro the hyphen is replaced by an underscore&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's quick do this with standard python code, but why are there this difference and can arcpy be changed to behave the same?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2025 13:47:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/validatetablename-inconsistent/m-p/1573081#M73473</guid>
      <dc:creator>MortenBackNielsen</dc:creator>
      <dc:date>2025-01-07T13:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: ValidateTableName inconsistent</title>
      <link>https://community.esri.com/t5/python-questions/validatetablename-inconsistent/m-p/1573143#M73474</link>
      <description>&lt;P&gt;I have reported a similar &lt;A href="https://support.esri.com/en-us/bug/running-the-arcpyvalidatetablenametnws-within-notebooks-bug-000166329" target="_self"&gt;bug&lt;/A&gt;&amp;nbsp;in 2024 which has yet to be resolved. Clearly the function is buggy and needs ESRI to resolve it.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2025 15:27:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/validatetablename-inconsistent/m-p/1573143#M73474</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2025-01-07T15:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: ValidateTableName inconsistent</title>
      <link>https://community.esri.com/t5/python-questions/validatetablename-inconsistent/m-p/1575460#M73554</link>
      <description>&lt;P&gt;According to the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/validatetablename.htm" target="_self"&gt;documentation&lt;/A&gt; , The function expects a workspace argument. When in the context of a project, that parameter is implied as "CURRENT" or the current working directory. If you are outside an active workspace or running your interpreter from outside a workspace that the table name can be validated against that value will not be a valid workspace.&lt;/P&gt;&lt;P&gt;This function is implemented in the C binaries, so I can't review how it is written. It seems to just return the input value if the workspace parameter is invalid. This behavior is a bit buggy (It should raise an Exception!), but to get around it, you just need to explicitly pass a workspace to the function call.&lt;/P&gt;&lt;P&gt;If all you want is to do some string substitution, you could wrap the ValidateTableName function like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcpy import ValidateTableName

def validate_table_name(table_name: str) -&amp;gt; str:
    validated_name = ValidateTableName(table_name)
    if validated_name == table_name:
        for character in (' ', '-', '.'): # add more as needed
            validated_name = validated_name.replace(character, "_")
    return validated_name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 21:19:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/validatetablename-inconsistent/m-p/1575460#M73554</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-01-15T21:19:30Z</dc:date>
    </item>
  </channel>
</rss>

