<?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 Nothing Happens When I run arcpy.management.AlterField() in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275046#M67334</link>
    <description>&lt;P&gt;I'm trying to write a function that takes in a feature class and converts all its field names to uppercase, using the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/alter-field-properties.htm" target="_self"&gt;Alter Field tool&lt;/A&gt;. Here is my code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def capitalize_fc_fnames(in_fc):
    # capitalizes all field names for specified feature class
    print("\nCapitalizing all field names for master network output feature class..")
    all_fields = [f.name for f in arcpy.ListFields(in_fc)]
    for f in all_fields:
        arcpy.management.AlterField(in_fc, f, new_field_name=f.upper())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running the function on a feature class in a file geodatabase. The function runs without errors, but when I open the feature class, none of the fields have been altered.&lt;/P&gt;&lt;P&gt;I have also tested in Pro using the Alter Field GUI tool on just one field, but with that nothing happens: no errors, no changes to the field names.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/geoprocessing-questions/alter-field-does-not-alter-the-field-when-changing/td-p/243305" target="_self"&gt;This post from 2017&lt;/A&gt; suggests that at that time it was a known but unresolved bug that Alter Field did nothing. I *really* hope that's not still the case as I have 90+ fields I want to convert to uppercase. &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/124461"&gt;@BrandonFlessner&lt;/a&gt; did you ever find a solution to this? &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt; do you have any sage input on this?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
    <pubDate>Tue, 04 Apr 2023 00:40:14 GMT</pubDate>
    <dc:creator>DarrenConly</dc:creator>
    <dc:date>2023-04-04T00:40:14Z</dc:date>
    <item>
      <title>Nothing Happens When I run arcpy.management.AlterField()</title>
      <link>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275046#M67334</link>
      <description>&lt;P&gt;I'm trying to write a function that takes in a feature class and converts all its field names to uppercase, using the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/alter-field-properties.htm" target="_self"&gt;Alter Field tool&lt;/A&gt;. Here is my code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def capitalize_fc_fnames(in_fc):
    # capitalizes all field names for specified feature class
    print("\nCapitalizing all field names for master network output feature class..")
    all_fields = [f.name for f in arcpy.ListFields(in_fc)]
    for f in all_fields:
        arcpy.management.AlterField(in_fc, f, new_field_name=f.upper())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running the function on a feature class in a file geodatabase. The function runs without errors, but when I open the feature class, none of the fields have been altered.&lt;/P&gt;&lt;P&gt;I have also tested in Pro using the Alter Field GUI tool on just one field, but with that nothing happens: no errors, no changes to the field names.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/geoprocessing-questions/alter-field-does-not-alter-the-field-when-changing/td-p/243305" target="_self"&gt;This post from 2017&lt;/A&gt; suggests that at that time it was a known but unresolved bug that Alter Field did nothing. I *really* hope that's not still the case as I have 90+ fields I want to convert to uppercase. &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/124461"&gt;@BrandonFlessner&lt;/a&gt; did you ever find a solution to this? &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt; do you have any sage input on this?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 00:40:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275046#M67334</guid>
      <dc:creator>DarrenConly</dc:creator>
      <dc:date>2023-04-04T00:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: Nothing Happens When I run arcpy.management.AlterField()</title>
      <link>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275052#M67335</link>
      <description>&lt;P&gt;syntax looks fine, but I would exclude fields that are not editable or required in your list comprehension&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/field.htm" target="_blank"&gt;Field—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The only things that bug me right now are:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&amp;nbsp;is the full path to the featureclass passed to the script?&lt;/LI&gt;&lt;LI&gt;where are you running the function from (separate IDE, python IDE, notebook??)&lt;/LI&gt;&lt;LI&gt;when you open the featureclass.... it won't update unless run from a script tool in arctoolbox or the python window.&lt;/LI&gt;&lt;LI&gt;and.... is this a network dataset? (I think they have other constraints compared to "regular" featureclasses)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 01:01:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275052#M67335</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-04-04T01:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Nothing Happens When I run arcpy.management.AlterField()</title>
      <link>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275097#M67336</link>
      <description>&lt;P&gt;I wonder if this is the extension of how it also has problems when trying to do it in catalog- it wont change cases if the names are the same. Just reverts back to whatever case it was... I'd try appending a temp value and then change it back to the desired name:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def capitalize_fc_fnames(in_fc):
    # capitalizes all field names for specified feature class
    print("\nCapitalizing all field names for master network output feature class..")
    all_fields = [f.name for f in arcpy.ListFields(in_fc)]
    for f in all_fields:
        arcpy.management.AlterField(in_fc, f, new_field_name=f'{f.upper()}_cmon')
        arcpy.management.AlterField(in_fc, f'{f.upper()}_cmon', new_field_name=f.upper())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 05:31:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275097#M67336</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-04-04T05:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Nothing Happens When I run arcpy.management.AlterField()</title>
      <link>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275289#M67340</link>
      <description>&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&amp;nbsp;is the full path to the featureclass passed to the script? &lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;Yes&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;where are you running the function from (separate IDE, python IDE, notebook??)&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt; In a separate IDE in a python script, but I tested in Pro's python command prompt as well. Neither worked.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;when you open the featureclass.... it won't update unless run from a script tool in arctoolbox or the python window. &lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;I was running from the python command prompt in pro&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;and.... is this a network dataset? (I think they have other constraints compared to "regular" featureclasses) &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;No, just a line feature data set&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;@Anonymous User'&lt;/STRONG&gt;s answer seems to work (i.e., change to a different name, then change back to the capitalized version of the original name). But that's still not ideal because it moves the field name to the end.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 14:38:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275289#M67340</guid>
      <dc:creator>DarrenConly</dc:creator>
      <dc:date>2023-04-04T14:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Nothing Happens When I run arcpy.management.AlterField()</title>
      <link>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275292#M67341</link>
      <description>&lt;P&gt;Hi Jeff,&lt;/P&gt;&lt;P&gt;This seems to work after testing out in the Pro python window. This approach also seems to move the field to the end, which is not ideal. I might end up using it if nothing else comes to mind.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 14:42:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275292#M67341</guid>
      <dc:creator>DarrenConly</dc:creator>
      <dc:date>2023-04-04T14:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: Nothing Happens When I run arcpy.management.AlterField()</title>
      <link>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275308#M67342</link>
      <description>&lt;P&gt;This might be a view/cache thing, or under the hood (more likely) it is creating a new field with the new name, and then doing a migrate from the old field so that would put them at the end.&amp;nbsp; If you could, can you create a new FC and field map the data to the uppercased fields? then save over the old?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 15:01:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1275308#M67342</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-04-04T15:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Nothing Happens When I run arcpy.management.AlterField()</title>
      <link>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1563980#M73266</link>
      <description>&lt;P&gt;solved my dilema:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Was
def convert_field_names_to_lowercase(fc):
    """
    Converts the field names of a feature class to lowercase.

    Args:
        fc (str): The path to the feature class.
    """

    try:
        fields = arcpy.ListFields(fc)
        for field in fields:
            new_name = field.name.lower()
            if new_name != field.name:
                arcpy.AlterField_management(fc, field.name, new_name)
                print(f"Renamed field: {field.name} to {new_name}")
Now is 

            if new_name != field.name and field.name not in ["OBJECTID","Shape_Length","Shape_Area","GlobalID", "Shape"]:
                arcpy.AlterField_management(fc, field.name, temp_name)
                print(f"Renamed field: {field.name} to {temp_name}")

                arcpy.AlterField_management(fc, temp_name, new_name)
                print(f"Renamed field: {temp_name} to {new_name}")
                print("---")&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 03 Dec 2024 06:12:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nothing-happens-when-i-run-arcpy-management/m-p/1563980#M73266</guid>
      <dc:creator>GrahamWood-HWC</dc:creator>
      <dc:date>2024-12-03T06:12:34Z</dc:date>
    </item>
  </channel>
</rss>

