Hi I am very new to ArcGis and Python
I recently had a data change that broke SpatialJoin line in a script we run to compile ArcGIS data for a database import.
The data in the ORD_NUM field can now get to be longer than 25 characters long.
arcpy.SpatialJoin_analysis(
parcel, ConditionalUse, parcel_conuse, "JOIN_ONE_TO_ONE", "KEEP_ALL", "PARCEL_ID \"PARCEL_ID\" true true false 50 Text 0 0 ,First,#,"
+vars.path_to_database+"/Parcel.mdb/Parcel/PARCEL_Limits,PARCEL_ID,-1,-1;ORD_NUM \"ORD_NUM\" true true false 25 Text 0 0 ,Join,\",\","
+vars.path_to_database+"/CommDev.mdb/CommDev/ConditionalUse,ORD_NUM,-1,-1", "INTERSECT", "-1 Feet", "")
My original answer to this issue was to change the field length here to 50. However that broke the database process and unfortunately I can not change that process right now.
So instead I would like to change this line so it truncates the data to 25 characters for the ORD_NUM field instead of failing like it does now.
This is a temporary fix until the database process can be adjust to handle the longer data. I tried setting the -1, -1 to 0, 25 but that didn't fix the issue. It still errored.
Is there anything else I can do to this line to force it to truncate the data at 25 characters instead of failing?
Thank you!!
Hi Cynthia,
I would recommend manually running it with formatting on the field you want, currently with the parameters you have set, it is not controlling the position of the text that is carried over.
http://resources.arcgis.com/en/help/main/10.2/index.html#//00210000000s000000
DISTRICTURL "District Website" true true false 100 Text 0 0 ,First,#,filepath/CountyDistrict,DISTRICTURL,0,25
This is what my field mapping for truncating the text on a field looked like, note it changes the character range at the very end 0,25.
Hi!
That link unfortunately doesn't take me to any useful page.
How do you set the formatting in Python?
Thank you!
try just copying and pasting the link, unfortunately GeoNET has a nasty problem truncating links when clicked.
The easiest way to get the proper formatting for your dataset will be to run it manually with the formatting of the start and end position. You can then go to the geoprocessing results tab, and copy the tool as a python snippet and put the part you need into your script.
I would guess based off of your code you posted you would need to replace this:
+vars.path_to_database+"/Parcel.mdb/Parcel/PARCEL_Limits,PARCEL_ID,-1,-1;ORD_NUM \"ORD_NUM\" true true false 25 Text 0 0 ,Join,\",\","
with this based on the parameters I used:
+vars.path_to_database+"/Parcel.mdb/Parcel/PARCEL_Limits,PARCEL_ID,-1,-1;ORD_NUM \"ORD_NUM\" true true false 25 Text 0 0 ,Join,#,vars.path_to_database+"/Parcel.mdb/Parcel/PARCEL_Limits,ORD_NUM,0,25
Again I would recommend running it manually and making sure all the tool syntax is correct.