1

I work for an organization that just upgraded from esri arcmap 9.3.1 to 10.2.1 and I'm currently in the process of updating the python scripts. When running a script I'm getting hung up on a portion that imports data from a database connection. The portion of the script is below:

arcpy.MakeTableView_management(ext_parcel_base, view_parcel_base_temp, "status = 'A'", "", "lrsn lrsn VISIBLE NONE;last_update last_update VISIBLE NONE;status status HIDDEN NONE;parcel_id parcel_id VISIBLE NONE;parent_lrsn parent_lrsn HIDDEN NONE;parent_parcel_id parent_parcel_id HIDDEN NONE;county_number county_number HIDDEN NONE;township_number township_number HIDDEN NONE;district_number district_number HIDDEN NONE;corporation_id corporation_id HIDDEN NONE;section_plat section_plat HIDDEN NONE;routing_number routing_number HIDDEN NONE;neighborhood neighborhood VISIBLE NONE;property_class property_class VISIBLE NONE;prop_street prop_street VISIBLE NONE;prop_city prop_city VISIBLE NONE;prop_state prop_state VISIBLE NONE;prop_zip prop_zip VISIBLE NONE;number_cards number_cards HIDDEN NONE;owner1 owner1 VISIBLE NONE;owner2 owner2 VISIBLE NONE;own_street own_street VISIBLE NONE;own_city own_city VISIBLE NONE;own_state own_state VISIBLE NONE;own_zip own_zip VISIBLE NONE;tax_bill_id tax_bill_id HIDDEN NONE;assoc_parcel_id assoc_parcel_id HIDDEN NONE;assemblage_parcel assemblage_parcel HIDDEN NONE;lock_flag lock_flag HIDDEN NONE;reval_neigh reval_neigh HIDDEN NONE;hmstd_code hmstd_code HIDDEN NONE;assoc_name assoc_name HIDDEN NONE;deed_book deed_book HIDDEN NONE;deed_page deed_page HIDDEN NONE;condo_pct_int condo_pct_int HIDDEN NONE;condo_field1 condo_field1 HIDDEN NONE;condo_field2 condo_field2 HIDDEN NONE;condo_field3 condo_field3 HIDDEN NONE;future_hmstd_code future_hmstd_code HIDDEN NONE;hmstd_eff_year hmstd_eff_year HIDDEN NONE;par_base_int1 par_base_int1 HIDDEN NONE;par_base_int2 par_base_int2 HIDDEN NONE;par_base_int3 par_base_int3 HIDDEN NONE;par_base_flag1 par_base_flag1 HIDDEN NONE;par_base_flag2 par_base_flag2 HIDDEN NONE;nei_rating nei_rating HIDDEN NONE;legal_acreage legal_acreage VISIBLE NONE;contract_owner1 contract_owner1 HIDDEN NONE;contract_owner2 contract_owner2 HIDDEN NONE;contract_street contract_street HIDDEN NONE;contract_city contract_city HIDDEN NONE;contract_state contract_state HIDDEN NONE;contract_zip contract_zip HIDDEN NONE;value_allocation value_allocation HIDDEN NONE;nei_rating2 nei_rating2 HIDDEN NONE;condo_type condo_type HIDDEN NONE;condo_level condo_level HIDDEN NONE")

arcpy.TableToTable_conversion(view_parcel_base_temp, sde, "parcel_base_temp", "", "lrsn 'lrsn' true true false 4 Long 0 10 ,First,#,"+ ext_parcel_base +",lrsn,-1,-1;last_update 'last_update' true true false 16 Date 0 0 ,First,#,"+ ext_parcel_base +",last_update,-1,-1;parcel_id 'parcel_id' true true false 26 Text 0 0 ,First,#,"+ ext_parcel_base +",parcel_id,-1,-1;neighborhood 'neighborhood' true true false 4 Long 0 10 ,First,#,"+ ext_parcel_base +",neighborhood,-1,-1;property_class 'property_class' true true false 4 Long 0 10 ,First,#,"+ ext_parcel_base +",property_class,-1,-1;prop_street 'prop_street' true true false 40 Text 0 0 ,First,#,"+ ext_parcel_base +",prop_street,-1,-1;prop_city 'prop_city' true true false 30 Text 0 0 ,First,#,"+ ext_parcel_base +",prop_city,-1,-1;prop_state 'prop_state' true true false 2 Text 0 0 ,First,#,"+ ext_parcel_base +",prop_state,-1,-1;prop_zip 'prop_zip' true true false 10 Text 0 0 ,First,#,"+ ext_parcel_base +",prop_zip,-1,-1;owner1 'owner1' true true false 36 Text 0 0 ,First,#,"+ ext_parcel_base +",owner1,-1,-1;owner2 'owner2' true true false 36 Text 0 0 ,First,#,"+ ext_parcel_base +",owner2,-1,-1;own_street 'own_street' true true false 40 Text 0 0 ,First,#,"+ ext_parcel_base +",own_street,-1,-1;own_city 'own_city' true true false 30 Text 0 0 ,First,#,"+ ext_parcel_base +",own_city,-1,-1;own_state 'own_state' true true false 2 Text 0 0 ,First,#,"+ ext_parcel_base +",own_state,-1,-1;own_zip 'own_zip' true true false 10 Text 0 0 ,First,#,"+ ext_parcel_base +",own_zip,-1,-1;legal_acreage 'legal_acreage' true true false 8 Double 4 10 ,First,#,"+ ext_parcel_base +",legal_acreage,-1,-1", "")

arcpy.AddIndex_management(sde_parcel_base_temp, "parcel_id", "parcelid", "NON_UNIQUE", "NON_ASCENDING")

This results in an error:

File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\conversion.py", line 2018, in TableToTable raise e ExecuteError: ERROR 001156: Failed on input OID -1, could not write value ' ' to output field prop_city Failed to execute (TableToTable).

I'm not very advanced in python and i understand it means:

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.

Do you have an idea what i need to do to fix this?

5
  • 1
    At a quick glance, your SQL statement "status = 'A'" doesn't look like it has the correct syntax. Normally it would be "status" = 'A' Give that a try.
    – amasephy
    May 20, 2014 at 18:24
  • i.e. replace it with "\"status\" = 'A'" or ''' "status" = 'A' '''
    – nmpeterson
    May 20, 2014 at 18:37
  • I gave that a try an still resulted in the same error. Any other ideas?
    – user7418
    May 20, 2014 at 18:56
  • Sorry to ask, but did you make sure that prop_city in the input table is a text field with less than 30 characters ?
    – radouxju
    May 20, 2014 at 20:17
  • Yes i did. This is the same script that we've been using for the past 5+ years with 9.3.1 pulling out of the same database. Just not quite sure what would be different in the newer version of python that is giving me problems, if that is even what the problem is..
    – user7418
    May 20, 2014 at 20:47

2 Answers 2

1

If you installed the 64bit background geoprocessing when you upgraded, this can effect some tools since not all features are supported in 64bit.

Also since you are just using Geoprocessing tasks you could quickly create this in model builder and export your model to a script to see if you have any syntax issues as well or if it actually works within a model.

2
  • That's probably better as a comment than an answer @nicholas, though you do make a good point. Try it in a model first, and if necessary export just that to python and see what it's doing differently. Without knowing the values of the variables, the contents of the table and heaps of other stuff it's hard to formulate an answer. May 20, 2014 at 23:45
  • 1
    I would advise against exporting a model to a Python script, especially on just a few lines of code like this, if you run the tools manually, then use Copy As Python Snippet from the result in the Geoprocessing | Results window I think you will find it simpler to debug. This is an aside but I think an Answer is better written as statements rather than more questions.
    – PolyGeo
    May 21, 2014 at 7:25
0

It's been a while, and you may have solved this by now, but I thought I'd chime in as I found this question while looking around for solutions struggling with the same ExecuteError ...

I have a similar code that copies tables from one database to another using arcpy.TableToTable_conversion in a similar fashion as you do. What I can see from the code posted is that your 'in_rows' (view_parcel_base_temp) is different from the path used in the field mapping (ext_parcel_base). Could that be the culprit?

Also, I haven't seen the need to create a table view here in my script. In my code I select a few fields to copy (like the ones you list in the field mapping) and use the where statement in MakeTableView to select on status. Any fields in in_rows not listed in the field mapping won't be copied.

I would replace your first two lines with this:

where_clause = """ "status" = 'A' """

arcpy.TableToTable_conversion(
    ext_parcel_base, sde, "parcel_base_temp", where_clause, ( " \
        lrsn            'lrsn'           true true false  4 Long   0 10 ,First,#,"+ ext_parcel_base +",lrsn,-1,-1; \
        last_update     'last_update'    true true false 16 Date   0  0 ,First,#,"+ ext_parcel_base +",last_update,-1,-1; \
        parcel_id       'parcel_id'      true true false 26 Text   0  0 ,First,#,"+ ext_parcel_base +",parcel_id,-1,-1; \
        neighborhood    'neighborhood'   true true false  4 Long   0 10 ,First,#,"+ ext_parcel_base +",neighborhood,-1,-1; \
        property_class  'property_class' true true false  4 Long   0 10 ,First,#,"+ ext_parcel_base +",property_class,-1,-1; \
        prop_street     'prop_street'    true true false 40 Text   0  0 ,First,#,"+ ext_parcel_base +",prop_street,-1,-1; \
        prop_city       'prop_city'      true true false 30 Text   0  0 ,First,#,"+ ext_parcel_base +",prop_city,-1,-1; \
        prop_state      'prop_state'     true true false  2 Text   0  0 ,First,#,"+ ext_parcel_base +",prop_state,-1,-1; \
        prop_zip        'prop_zip'       true true false 10 Text   0  0 ,First,#,"+ ext_parcel_base +",prop_zip,-1,-1; \
        owner1          'owner1'         true true false 36 Text   0  0 ,First,#,"+ ext_parcel_base +",owner1,-1,-1; \
        owner2          'owner2'         true true false 36 Text   0  0 ,First,#,"+ ext_parcel_base +",owner2,-1,-1; \
        own_street      'own_street'     true true false 40 Text   0  0 ,First,#,"+ ext_parcel_base +",own_street,-1,-1; \
        own_city        'own_city'       true true false 30 Text   0  0 ,First,#,"+ ext_parcel_base +",own_city,-1,-1; \
        own_state       'own_state'      true true false  2 Text   0  0 ,First,#,"+ ext_parcel_base +",own_state,-1,-1; \
        own_zip         'own_zip'        true true false 10 Text   0  0 ,First,#,"+ ext_parcel_base +",own_zip,-1,-1; \
        legal_acreage   'legal_acreage'  true true false  8 Double 4 10 ,First,#,"+ ext_parcel_base +",legal_acreage,-1,-1 \
        ", "")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.