AnsweredAssumed Answered

Simple python tool for WKT extraction- diagnosing error?

Question asked by robin.h_SRRC on Oct 15, 2018
Latest reply on Oct 16, 2018 by dkwiens

Hi, I've written a short piece of code that takes a shapefile, copies to a .gdb, adds WKT attributes and outputs as an excel spreadsheet. The code is:

 

import arcpy
import os

###Get parameters as variables
inputshp = arcpy.GetParameterAsText(0)
ouputDest = arcpy.GetParameterAsText(1)
outputName = arcpy.GetParameterAsText(2)

###Copy shapefile to feature class in Default.gdb and add a field called WKT
intFC = arcpy.FeatureClassToFeatureClass_conversion(in_features = inputshp, out_path = arcpy.env.workspace, out_name = inputshp)
arcpy.AddField_management(in_table = intFC, field_name = "WKT", field_type = TEXT, field_length = 100000)

###Populate WKT column with WKT geometery
with arcpy.da.UpdateCursor(intFC,["WKT", "SHAPE@WKT"]) as cursor:
for row in cursor:
row[0] = row[1]
cursor.updateRow(row)

###Set output folder to output folder as given by user
arcpy.env.workspace = outputDest

###Create xls output
TableToExcel_conversion (intFC, outputName)

###Delete intermittent feature class
Delete_management (intFC)

print "Finished"

Thus is then implemented in a tool with input parameters of: Shapefile, destination folder and excel spreadsheet name. In trying to run the tool however, I keep receiving the error: 

 

Traceback (most recent call last):
File "S:\Works and Infrastructure Services\Infrastructure and Design\Technical Services\Asset Management\Robin\Python\AddWKT.py", line 10, in <module>
intFC = arcpy.FeatureClassToFeatureClass_conversion(in_features = inputshp, out_path = arcpy.env.workspace, out_name = inputshp)
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\conversion.py", line 1790, in FeatureClassToFeatureClass
raise e
ExecuteError: ERROR 999999: Error executing function.
Failed to execute (FeatureClassToFeatureClass).

 

I've tried and failed to diagnose this myself- I'm pretty new to python and this is a means to an end but also a learning experience- could anybody tell me what I'm doing wrong here?

 

Edit: If anyone can give me pointers on how to format a codeblock within this forum that would also be handy!

Outcomes