I am trying to convert all of xls files (including single sheet) a folder into dbf tables in a gdb.
Here is my code:
import arcpy, os, xlrd
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "C:/Users/****/Desktop/Assignment_5/excels.gdb"
# Excel is input, gdb is output directories
excel = "C:/Users/****/Desktop/Assignment_5/excel_files"
gdb = "C:/Users/****/Desktop/Assignment_5/excels.gdb"
# Walk through the folder for all xls files and convert them to dbf files
for root, dirs, files in os.walk(gdb):
for f in files:
outname = gdb + str(os.path.basename(f[:-4])) + ".dbf"
arcpy.ExcelToTable_conversion(f, outname)
What I get in shell is nothing more than this:
Traceback (most recent call last):
File "Y:/students/***/Assignments/Assignment_5/Assignment_5.py", line 32, in <module>
arcpy.ExcelToTable_conversion(f, outname)
File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\conversion.py", line 63, in ExcelToTable
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000814: Invalid file type
Failed to execute (ExcelToTable).
What is the problem is with my code?
.dbf
into a.gdb
because anything.dbf is not a valid table name. You can corrupt the file geodatabase from the operating system by dropping random files in the .gdb folder, but Desktop can't access those files. Your problem is incorrect naming.