Select to view content in your preferred language

Error with Feature Class to Shapefile in Python

674
1
03-07-2013 11:29 AM
GerryGabrisch
Frequent Contributor
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....

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.



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
Tags (2)
0 Kudos
1 Reply
MathewCoyle
Honored Contributor
I'd use Feature Class to Feature Class. Feature Class to Shapefile is more for bulk loading.
0 Kudos