Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Error with Feature Class to Shapefile in Python

$
0
0
I am trying to automate the conversion of several geodatabase feature classes to shapefile. The code below produces a shapefile in the output directory but then it throws this error....

Code:

PYTHON ERRORS:
Traceback info:
  File "C:\gtemp\ShareLummiData.py", line 12, in <module>
    arcpy.FeatureClassToShapefile_conversion(LummiReservation, OutputDirectory)

Error Info:
object of type 'dict' has no len()

ArcPy ERRORS:

I would like to duplicate this process for several feature classes. I could put an error handler here to catch the error in ESRI's code but if I do, I will not catch real errors. Any ideas would be helpful.



Code:

try:
   
    import arcpy, sys, traceback
    OutputDirectory = r"C:\gtemp\aa"
    LummiReservation = r"Z:\Data\Boundaries\Administrative\Lummi.gdb\TribalBoundaries\LummiReservation"
    arcpy.FeatureClassToShapefile_conversion(LummiReservation, OutputDirectory)


except arcpy.ExecuteError:
    # Get the tool error messages
    msgs = arcpy.GetMessages(2)
    # Return tool error messages for use with a script tool
    arcpy.AddError(msgs)
    # Print tool error messages for use in Python/PythonWin
    print msgs
except:
    # Get the traceback object
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    # Concatenate information together concerning the error into a message string
    pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
    msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
    # Return python error messages for use in script tool or Python Window
    arcpy.AddError(pymsg)
    arcpy.AddError(msgs)
    # Print Python error messages for use in Python / Python Window
    print pymsg + "\n"
    print msgs


Viewing all articles
Browse latest Browse all 2485

Trending Articles