<?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 How can I trim a field name in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-can-i-trim-a-field-name/m-p/82648#M6555</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;I have a script that copies fields from on feature class to another. But it stops running if it encounters a field name greater than 10 characters in the source file. I am wondering if it's possible to trim the field name to let the program keep running. Something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;... shp = 'WillCounty_Street_09282018.shp'&lt;BR /&gt;... index = 8&lt;BR /&gt;... fields = arcpy.ListFields(shp)&lt;BR /&gt;... for field in fields:&lt;BR /&gt;...&amp;nbsp; &amp;nbsp; &amp;nbsp;print ("name is", field.name, "length is", len(field.name))&lt;BR /&gt;...&amp;nbsp; &amp;nbsp; &amp;nbsp;if len(field.name) &amp;gt; index:&lt;BR /&gt;...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;field.name = field.name[0: index+1:]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made the index = 8 because the the feature class I am testing has no field names greater than 10. Of course that code works only works with strings. It runs but does not do the job of trimming the field names. Is it possible to do this?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 May 2019 15:24:52 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2019-05-14T15:24:52Z</dc:date>
    <item>
      <title>How can I trim a field name</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-trim-a-field-name/m-p/82648#M6555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;I have a script that copies fields from on feature class to another. But it stops running if it encounters a field name greater than 10 characters in the source file. I am wondering if it's possible to trim the field name to let the program keep running. Something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;... shp = 'WillCounty_Street_09282018.shp'&lt;BR /&gt;... index = 8&lt;BR /&gt;... fields = arcpy.ListFields(shp)&lt;BR /&gt;... for field in fields:&lt;BR /&gt;...&amp;nbsp; &amp;nbsp; &amp;nbsp;print ("name is", field.name, "length is", len(field.name))&lt;BR /&gt;...&amp;nbsp; &amp;nbsp; &amp;nbsp;if len(field.name) &amp;gt; index:&lt;BR /&gt;...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;field.name = field.name[0: index+1:]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made the index = 8 because the the feature class I am testing has no field names greater than 10. Of course that code works only works with strings. It runs but does not do the job of trimming the field names. Is it possible to do this?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 May 2019 15:24:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-trim-a-field-name/m-p/82648#M6555</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-05-14T15:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can I trim a field name</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-trim-a-field-name/m-p/82649#M6556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is a shapefile problem, gdb featureclass tables don't have this problem&lt;/P&gt;&lt;P&gt;but you could include ValidateFieldName in your code&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/get-started/working-with-geodatabases.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/get-started/working-with-geodatabases.htm"&gt;Validating table and field names in Python—ArcPy Get Started | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 May 2019 15:31:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-trim-a-field-name/m-p/82649#M6556</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-05-14T15:31:09Z</dc:date>
    </item>
  </channel>
</rss>

