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!
Solved! Go to Solution.
"Unreliable" may have been the wrong word. It tends to be harder to read, which could make it unreliable. It's easy to get messed up on the slashes and get one the wrong way, or accidentally add an extra one. Plus it's also less flexible than os.path. For example, instead of using string concatenation like this
attFolder = mapFolder + "/" + "6)Deliverables/4)Feature_Class_Attribute_Tables/" + version outATTgdb = 'attribute_tables.gdb' exportLoc = attFolder + "/" + outATTgdb
You can use os.path to define your pieces separately and put them all together in a more readable way without worrying about the slashes.
mapFolder = r"C:\temp" version = "v99" outATTgdb = "attribute_tables.gdb" attFolder = os.path.join(mapFolder, "6)Deliverables", "4)Feature_Class_Attribute_Tables", version) exportLoc = os.path.join(attFolder, outATTgdb)
Notice the r in front of the string for mapFolder. That specifies the string as "raw" so a single backslash doesn't need a second escape backslash. I find it easier this way so you can just copy/paste directory paths.
Okay, that makes more sense now. Thanks for the clarification.
just to make sure you aren't using 64 bit processing
ArcGIS Help (10.2, 10.2.1, and 10.2.2)
not supported
I am indeed using 64 bit background processing. Do you have any suggestions as to a workaround that doesn't result in me and everyone else that would use this tool having to install 32 bit libraries on top of the 64 bit libraries?
Thanks!
Coy
from the link I provided
Background Geoprocessing (64-bit) is available as a separate installation on top of ArcGIS for Desktop. The following information only applies if you have the Background Geoprocessing (64-bit) product installed; otherwise, background processing is done in 32 bit.
and the recommended workaround
The following data types are unsupported in 64-bit processing:
If your workflow involves any of the above data types, you can execute the tool in the foreground by disabling background processing or convert your data to a supported type, then execute the tool in the background.
I have background geoprocessing turned off, so I'm wondering if this isn't the issue.
I moved past this portion of the script and on to a different part that pulls the feature classes exactly how they are in the map and does the exact same thing (TableToTable and then TableToExcel). That part works just fine, so I'm thinking that there's no compatibility issues going on.
# Export TableToTable & TableToExcel # Set Local Variables exportTable = updatedTable # This table is the result of the summary statistics tool in the previous step exportLoc = kmfFolder + "/" + outKMFgdb outTable = "general_KMF" outXLS = "general_KMF.xls" # Execute TableToTable arcpy.TableToTable_conversion(exportTable, exportLoc, outTable, "", "", "") # this part works fine # Set Local Variables inTable = outTable # hoping to grab the result of the TableToTable function above # Execute TableToExcel arcpy.TableToExcel_conversion(inTable, outXLS)
In this instance, the TableToExcel keeps kicking back saying that the file type is invalid just as it did before, though. I've tried various ways of setting the inTable variable in line 13, but none of them have worked. I also tried to create a table view between the two tool functions and it still said invalid file type. I can't hard code the variable name because the location will be variable depending on the name of the map. Essentially the kmfFolder variable grabs the maps file location and adds a few characters that are standard between maps, and that is where everything is saved for the current map document.
Examples of what I've tried using for the inTable variable:
inTable = outKMFgdb + "/" + outTable
inTable = exportLoc + "/" + outTable
inTable = (combo of all above) + "/general_KMF"
inTable = (combo of all above) + "/general_KMF.dbf"
etc...
*NOTE*: I intend on implementing the os.path.join suggestion mentioned above, but I'm just trying to get it working for now. Since the method I am using works in other areas of the script, especially in areas that due essentially the same thing, I don't think it's what's causing this particular issue.
You should split this off into a new thread. From the original thread, no apparent resolution seems to be found. You should close it by turning it into a discussion or marking it assumed read or mark one of the threads as providing the answer. At 15+ posts long, it is way too long to follow and new requests provide a confusing fork in the road
Duly noted for future reference. I ended up resolving the issue, though. Please see the code pasted below.
Thanks again for your help in this thread and all others. I've seen your name quite a bit in some of my threads, so thank you for all of your time.
I was looking at this the wrong way. I was assuming that the error was referring to the input table that was incorrect, but it was actually referring to the output file as being incorrect. Instead of simply giving the output a name, I gave it a save location with a name, and it worked just fine. See the code below:
# Set local variables inTable = outTable outXLS = kmfFolder + "/general_KMF.xls" #this is where I had to give the file path and then the file name # Execute TableToExcel arcpy.TableToExcel_conversion(inTable, outXLS) ersion(inTable, outXLS)