AnsweredAssumed Answered

Table to Excel within Python script

Question asked by Cep86 on Jun 16, 2015
Latest reply on Jun 13, 2017 by rastrauch

I'm trying to export my feature class to a table, and then also create a copy as an Excel document.  The following code keeps kicking back with an error saying that I am using the wrong file type.

 

Error message:

"Failed to execute. Parameters are not valid.

ERROR 000814: Invalid file type

Failed to execute (TableToExcel)."

 

Code:

##########
# Create a file geodatabase for attribute tables to be saved in
##########


# Set local variables - uses variables derived earlier in script
attFolder = mapFolder + "/" + "6)Deliverables/4)Feature_Class_Attribute_Tables/" + version
outATTgdb = 'attribute_tables.gdb'

# Execute CreateFileGDB
arcpy.CreateFileGDB_management(attFolder, outATTgdb, 'CURRENT')


##########
# General Features export
##########

# Set local variables
inTable = generalFeatures
exportLoc = attFolder + "/" + outATTgdb
outTable = "general_attributes"
outXLS = "general_attributes.xls"

# Execute TableToTable
arcpy.TableToTable_conversion(inTable, exportLoc, outTable)

arcpy.env.workspace = 'attFolder'

# Execute TableToExcel
arcpy.TableToExcel_conversion(inTable, outXLS)










 

I've tried modifying this a bit, with no positive results.  For the outXLS variable I tried to make it equal the entire save location, and then removed the arcpy.env.workspace variable, but everything that I have tried results in the same "invalid file type" error.

 

Any recommendations?

 

Thanks in advance!

Outcomes