ERROR 001156 when using Append

3388
4
Jump to solution
06-02-2017 01:23 PM
HannesZiegler2
Occasional Contributor II

Hi, I'm attempting to use append to add data from one table to another, but I am getting the below error (I am writing this in a script, but have tested the append tool in ArcMap as well with the same error):

Traceback (most recent call last):
File "C:\Users\zieglerhm\Documents\ArcGIS\Projects\CW2020_IRP_DataProcessing\Script\WorkSummaryDataImport_v0.2.py", line 184, in <module>
arcpy.management.Append(gm_reh_sum_mem, gm_reh_sum_target, "NO_TEST", gm_reh_sum_fldmap, "Mechanical Cleaning/Root Removal")
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 3995, in Append
raise e
ExecuteError: ERROR 001156: Failed on input OID 1, could not write value '' to output field REHABLENGTH
Failed to execute (Append).

The problem is that the field in the source table is of type string while the field being mapped to in the target table is of type double. I was under the impression that field mapping would automatically convert to the new field data type, and the following discussion seems to be using this principle: arcpy - Change Field Type using Field Mapping for List of Tables using Python - Geographic Informati... 

Has anyone encountered this error before, and if so, how did you solve it? Should field mapping change to the data type of the output field automatically?

Thank you for any help!

1 Solution

Accepted Solutions
DarrenWiens2
MVP Honored Contributor

Hmmm... this page seems to say it's not possible: 001156: Failed on input OID ; could not write value '' to output field .—Help | ArcGIS Desktop 

A value could not be added to the output field; for example, text values cannot be added to numeric fields, and text values cannot be added to text fields if the values are longer than the field length.

View solution in original post

4 Replies
DanPatterson_Retired
MVP Esteemed Contributor

There are a number of links on this error message... you will probably have to sift through them here

0 Kudos
DarrenWiens2
MVP Honored Contributor

Hmmm... this page seems to say it's not possible: 001156: Failed on input OID ; could not write value '' to output field .—Help | ArcGIS Desktop 

A value could not be added to the output field; for example, text values cannot be added to numeric fields, and text values cannot be added to text fields if the values are longer than the field length.

View solution in original post

curtvprice
MVP Esteemed Contributor

So, the workaround is to copy it to a numeric value before appending, and update your remap table.

arcpy.AddField_management(gm_reh_sum_mem, "REHABLENGTHF", "DOUBLE")
arcpy.CalculateField_management(gm_reh_sum_mem, REHABLENGTHF,
    "float(!REHABLENGTH!)", "PYTHON_9.3")
HannesZiegler2
Occasional Contributor II

Hmm, that's the only solution I have found as well, I was hoping there was a more elegant way of doing it. I actually can't believe that there isn't, esri should make it easier to change column attribute types when field mapping. I know that the table to table tool allows you to change the field type being copied out to, but I can't figure out how to accomplish that when using the table to table tool in python. Anyway, thank you guys for the help!

0 Kudos