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? I have gone through all websites, but could not figure this out!