<?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: Python Problem in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707448#M54826</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The actual Help page doesn't hep much... it just states that the alias is invalid and you should try a different alias. &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/001601_Failed_to_alter_field_alias/00vp00000038001601/" title="http://resources.arcgis.com/en/help/main/10.2/index.html#/001601_Failed_to_alter_field_alias/00vp00000038001601/"&gt;ArcGIS Help (10.2, 10.2.1, and 10.2.2)&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you print the &lt;EM&gt;str(fieldList&lt;I&gt;.name)&lt;/I&gt;&lt;/EM&gt;&lt;I&gt; and &lt;EM&gt;str(fullNames&lt;I&gt;)&lt;/I&gt;&lt;/EM&gt;&lt;I&gt; to see what it's trying to do? And you are using an empty string as the optional output field name. Are you sure that 's OK?&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it the first field where the error occurs or did it change some fields?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Dec 2014 03:27:45 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2014-12-03T03:27:45Z</dc:date>
    <item>
      <title>Python Problem</title>
      <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707447#M54825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to write a script that that changes the aliases of a table's fields, but when I ran it I got this code error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 001601: Failed to alter field alias.&lt;/P&gt;&lt;P&gt;Failed to execute (AlterField).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This makes no sense to me and I would love any input as to why this happened.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, here is my code that generated this error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import geoprocessing
import arcpy


# Set workspace
arcpy.env.workspace = r'U:\newberry\new.gdb'


# Creates a list of fields from the Metadata_2010 table
fieldListTable = arcpy.ListFields("METADATA_2010")


# Creates a cursor - a data access object
rows = arcpy.SearchCursor("METADATA_2010")


# Creates an empty table to store row values
fullNames = []


# For loop thats iterates through the rows in
# the Full_Name field of the Metadata_2010 table
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Adds the row value to the fullNames list
&amp;nbsp;&amp;nbsp;&amp;nbsp; fullNames.append(row.getValue(fieldListTable[2].name))


# Creates a sliced list of fields from the census block group
# polygon feature class
fieldList = arcpy.ListFields("please")[2:630]


# For loop thats changes the existing alias name in the table
# to the name in the fullNames list
for i in range(len(fieldList)):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AlterField_management('please', str(fieldList&lt;I&gt;.name),'',str(fullNames&lt;I&gt;))&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:43:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-problem/m-p/707447#M54825</guid>
      <dc:creator>DavidLeslie</dc:creator>
      <dc:date>2021-12-12T05:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python Problem</title>
      <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707448#M54826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The actual Help page doesn't hep much... it just states that the alias is invalid and you should try a different alias. &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/001601_Failed_to_alter_field_alias/00vp00000038001601/" title="http://resources.arcgis.com/en/help/main/10.2/index.html#/001601_Failed_to_alter_field_alias/00vp00000038001601/"&gt;ArcGIS Help (10.2, 10.2.1, and 10.2.2)&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you print the &lt;EM&gt;str(fieldList&lt;I&gt;.name)&lt;/I&gt;&lt;/EM&gt;&lt;I&gt; and &lt;EM&gt;str(fullNames&lt;I&gt;)&lt;/I&gt;&lt;/EM&gt;&lt;I&gt; to see what it's trying to do? And you are using an empty string as the optional output field name. Are you sure that 's OK?&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it the first field where the error occurs or did it change some fields?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 03:27:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-problem/m-p/707448#M54826</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-12-03T03:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Python Problem</title>
      <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707449#M54827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure about the empty string, but when I ran it without one it crashed immediately. Perhaps you would know the proper way&amp;nbsp; to skip over an optional field?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program did go about halfway through the renaming of aliases process and then stopped at this string:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SEX BY EDUCATIONAL ATTAINMENT FOR THE POPULATION 25 YEARS AND OVER - Universe:&amp;nbsp; Population 25 years and over - Total:&amp;nbsp; Male:&amp;nbsp; Doctorate degree -- (Estimate).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is interesting because the ones proceeding it are very similar. Any other suggestions for this problem would be great and thanks for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 18:07:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-problem/m-p/707449#M54827</guid>
      <dc:creator>DavidLeslie</dc:creator>
      <dc:date>2014-12-03T18:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Python Problem</title>
      <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707450#M54828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As an aside, Curtis Price wrote a nice primer on how to post code on the Geonet forums. Makes it much easier to read.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/1070"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 19:45:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-problem/m-p/707450#M54828</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-12-03T19:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Python Problem</title>
      <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707451#M54829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import geoprocessing
import arcpy
# Set workspace
arcpy.env.workspace = r'U:\newberry\new.gdb'

# Creates a list of fields from the Metadata_2010 table
fieldListTable = arcpy.ListFields("METADATA_2010")
&amp;nbsp; 
# Creates a cursor - a data access object
rows = arcpy.SearchCursor("METADATA_2010")
&amp;nbsp; 
# Creates an empty table to store row values
fullNames = []
&amp;nbsp; 
# For loop thats iterates through the rows in
# the Full_Name field of the Metadata_2010 table
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Adds the row value to the fullNames list
&amp;nbsp;&amp;nbsp;&amp;nbsp; fullNames.append(row.getValue(fieldListTable[2].name))
&amp;nbsp; 
# Creates a sliced list of fields from the census block group
# polygon feature class
fieldList = arcpy.ListFields("please")[2:630]
&amp;nbsp; 
# For loop thats changes the existing alias name in the table
# to the name in the fullNames list
for i in range(len(fieldList)):
&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AlterField_management('please', str(fieldList&lt;I&gt;.name),'',str(fullNames&lt;I&gt;))&lt;/I&gt;&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; except Exception as e:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print('FieldList name is: {0}\n
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fullName is: {1}\n
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Error: {2}'.format(fieldList&lt;I&gt;.name, fullNames&lt;I&gt;, e.message)&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might want to consider using an arcpy.da.SearchCursor, much faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I added a try statement to catch the error and show the problematic values. I think the root of the problem may be in the code building your lists, but am not sure, having a hard time working out the details.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:43:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-problem/m-p/707451#M54829</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2021-12-12T05:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Python Problem</title>
      <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707452#M54830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Upon further inspection of my census block group data (which includes: a feature class (polygon) and a metadata table) I found that the feature class had an additional field, OBJECTID_1, that was not included in the metadata table. After I deleted that field from the feature class, the program ran just fine except for an out or range error, which i'm assuming has to do with the use of len(fieldList) in the for loop. I really appreciate the quick responses.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 20:31:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-problem/m-p/707452#M54830</guid>
      <dc:creator>DavidLeslie</dc:creator>
      <dc:date>2014-12-03T20:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Python Problem</title>
      <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707453#M54831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you working with the 5 year ACS estimates? Working on that myself right now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 21:32:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-problem/m-p/707453#M54831</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-12-03T21:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python Problem</title>
      <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707454#M54832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes I am.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 21:35:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-problem/m-p/707454#M54832</guid>
      <dc:creator>DavidLeslie</dc:creator>
      <dc:date>2014-12-03T21:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Python Problem</title>
      <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707455#M54833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Those field names aren't helpful, are they? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 22:30:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-problem/m-p/707455#M54833</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-12-03T22:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: Python Problem</title>
      <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707456#M54834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you don't mind, where did you get the field names for the data? The metadata file I have has short name (B23003e1) with a text description which can be very long. I've been using the description as a field name, but they get truncated when I pull them into a gdb table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 16:19:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-problem/m-p/707456#M54834</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-12-05T16:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python Problem</title>
      <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707457#M54835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did not use the descriptions from the metadata as field names, I used them as aliases. I'm guessing that replacing field names have some limitations on the length, where alias don't .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've attached a picture of what a portion of my table looks like.&lt;IMG alt="table.PNG" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/37629_table.PNG" style="width: 620px; height: 362px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 17:11:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-problem/m-p/707457#M54835</guid>
      <dc:creator>DavidLeslie</dc:creator>
      <dc:date>2014-12-05T17:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Python Problem</title>
      <link>https://community.esri.com/t5/python-questions/python-problem/m-p/707458#M54836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. I may use this myself. I did write a script to delete the 'Margin of Error' fields. Not relevant for our uses, and they double the number of fields. My data wasn't joined to the polygon file, though, when I downloaded it. Relationship classes are there, but not actually working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 18:08:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-problem/m-p/707458#M54836</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-12-05T18:08:18Z</dc:date>
    </item>
  </channel>
</rss>

