<?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: AppendManagement failing because of field widths in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1157604#M64155</link>
    <description>&lt;P&gt;To answer your original question - One way around this is something like this...&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;fld1 = "your field that's too long"
fld2 = "another"
desc = arcpy.Describe(table)
for fld_obj in desc.fields()
    if fld.name == fld1:
        fld1_len = fld.length
    if fld.name == fld2:
        fld2_len = fld.length
with arcpy.da.UpdateCursor("your table", ["fld1", "fld2"]) as uCur:
    for uRow in uCur:
        uRow[0] = value_too_long[:fld1_len]
        uRow[1] = value_too_long[:fld2_len]
        uCur.updateRow(uRow)&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;&lt;P&gt;the&amp;nbsp;value_too_long[:fld2_len] is a string slice that goes up to the length identified in the first part. (it may need a "fld2_len - 1" if it's still too long.&lt;/P&gt;&lt;P&gt;disclaimer: this is off the top of my head which is more 2.7 based. Also, getting the value_too_long value is hard for me to guess since I don't know where it's coming from. if it's another field inthe same table, you would add it to the list of fields in the UpdateCursor initialization&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;edit: since you already know their lengths, you could skip the first section and just put it in the value_too_long&lt;/P&gt;&lt;PRE&gt;for fld_obj in desc.fields()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Mar 2022 22:22:49 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2022-03-24T22:22:49Z</dc:date>
    <item>
      <title>AppendManagement failing because of field widths</title>
      <link>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1156764#M64130</link>
      <description>&lt;P&gt;I have a script running that is updating an SDE feature class from a parcel fabric feature class..&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;The script is failing because two fields in the target database are not wide enough.&lt;/P&gt;&lt;P&gt;Field 1 - 50 in the source , 20 in the target&lt;/P&gt;&lt;P&gt;Field 2 - 2000 in the source 25 in the target&lt;/P&gt;&lt;P&gt;I've tested and verified that appendmanagement will run fine if I alter the field widths in the target database.&lt;/P&gt;&lt;P&gt;I'd rather not do that and was wondering if there is a way to have appendmanagment just truncate the values at 20 and 25 when it does the append.&lt;/P&gt;&lt;P&gt;Feedback is greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 15:38:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1156764#M64130</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-03-23T15:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: AppendManagement failing because of field widths</title>
      <link>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1156843#M64131</link>
      <description>&lt;P&gt;Did you try schema_type="NO_TEST" and the &lt;SPAN&gt;arcpy.Append_management call&lt;/SPAN&gt;?&amp;nbsp; This allows appends when schemas don't match, however I suspect it will still fail if you have a value in one of those two fields that does not fit in the target column. But it might be worth a try.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 16:54:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1156843#M64131</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2022-03-23T16:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: AppendManagement failing because of field widths</title>
      <link>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1156997#M64136</link>
      <description>&lt;P&gt;Thanks for that suggestion. In a test database I altered the widths of the fields to match the source database. It's not ideal but i figured I could at least test the results.&lt;/P&gt;&lt;P&gt;Unfortunately the field calc part of the script is failing now.&lt;/P&gt;&lt;P&gt;The fields as exported from the parcel feature class ended up being called&amp;nbsp;&lt;/P&gt;&lt;P&gt;SHAPE.STArea() and SHAPE.STLength()&lt;/P&gt;&lt;P&gt;I can't seem to get the correct syntax to add two new fields (AREA and PERMIETER) and calculate the new fields to these fields before deleting them.&lt;/P&gt;&lt;P&gt;When I call AddField it's naming the field&amp;nbsp;Database_SCHEMA_featureclass.AREA instead of just AREA.&lt;/P&gt;&lt;P&gt;Here are the lines:&lt;BR /&gt;&lt;FONT size="2"&gt;arcpy.AddField_management(feature_lyr_out , "AREA", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;arcpy.CalculateField_management(feature_lyr_out , "AREA", "[!SHAPE.STArea()!]", "PYTHON_9.3", "")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;arcpy.DeleteField_management(feature_lyr_out , "![SHAPE.STArea()]!")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I'm wondering if the system is having trouble resolving the field names that include . and () characters.&lt;/P&gt;&lt;P&gt;Feedback is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 20:31:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1156997#M64136</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-03-23T20:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: AppendManagement failing because of field widths</title>
      <link>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1157003#M64137</link>
      <description>&lt;P&gt;These are the fields:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="test.JPG" style="width: 897px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37176iB98D61E891834C65/image-size/large?v=v2&amp;amp;px=999" role="button" title="test.JPG" alt="test.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 20:40:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1157003#M64137</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-03-23T20:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: AppendManagement failing because of field widths</title>
      <link>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1157026#M64138</link>
      <description>&lt;P&gt;Try using&amp;nbsp;"!shape.area!" in your expression instead of&amp;nbsp;&lt;SPAN&gt;"![SHAPE.STArea()]!".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm not sure why it is prepending the field with the schema name but perhaps "area" is a reserved name and you should try something else like "my_area".&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 21:19:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1157026#M64138</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2022-03-23T21:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: AppendManagement failing because of field widths</title>
      <link>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1157594#M64151</link>
      <description>&lt;P&gt;I believe the NO_TEST will still fail at the DB level.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 21:52:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1157594#M64151</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-03-24T21:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: AppendManagement failing because of field widths</title>
      <link>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1157598#M64153</link>
      <description>&lt;P&gt;It's failing because "area" is a reserved keyword in an SDE table. You'll have to name it "my_area" (or something) to add that field without the inserted qualifications&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 21:56:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1157598#M64153</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-03-24T21:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: AppendManagement failing because of field widths</title>
      <link>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1157604#M64155</link>
      <description>&lt;P&gt;To answer your original question - One way around this is something like this...&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;fld1 = "your field that's too long"
fld2 = "another"
desc = arcpy.Describe(table)
for fld_obj in desc.fields()
    if fld.name == fld1:
        fld1_len = fld.length
    if fld.name == fld2:
        fld2_len = fld.length
with arcpy.da.UpdateCursor("your table", ["fld1", "fld2"]) as uCur:
    for uRow in uCur:
        uRow[0] = value_too_long[:fld1_len]
        uRow[1] = value_too_long[:fld2_len]
        uCur.updateRow(uRow)&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;&lt;P&gt;the&amp;nbsp;value_too_long[:fld2_len] is a string slice that goes up to the length identified in the first part. (it may need a "fld2_len - 1" if it's still too long.&lt;/P&gt;&lt;P&gt;disclaimer: this is off the top of my head which is more 2.7 based. Also, getting the value_too_long value is hard for me to guess since I don't know where it's coming from. if it's another field inthe same table, you would add it to the list of fields in the UpdateCursor initialization&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;edit: since you already know their lengths, you could skip the first section and just put it in the value_too_long&lt;/P&gt;&lt;PRE&gt;for fld_obj in desc.fields()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 22:22:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appendmanagement-failing-because-of-field-widths/m-p/1157604#M64155</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-03-24T22:22:49Z</dc:date>
    </item>
  </channel>
</rss>

