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?

  • 2
    You can't place dBase files in a file geodatabase. Once in FGDB, they become tables, and tables do not support anything but alpha, numeric and underscore characters in their names.
    – Vince
    Nov 3, 2019 at 20:26
  • Thank you for your comment @Vince, but that is not correct as it is possible to place dbf files in a GDB! I was just curious how I can handle this. I actually need to Convert the excel files to a temporary table, using arcpy.ExcelToTable_conversion(). Nov 3, 2019 at 21:13
  • 1
    When a dBase file or Excel spreadsheet canvas is copied to a file geodatabase table, it is converted into a file geodatabase table, and is no longer in the source format. It is not possible for ArcGIS to place a .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.
    – Vince
    Nov 3, 2019 at 23:06
  • I now see what you meant. Yeah you are right on that as the format changes once in the GDB. I misinterpreted your statements. I can also sense that my problem is with naming, but do you have any suggestions? Nov 4, 2019 at 16:14
  • 1
    Not adding ".dbf" would be a logical first step.
    – Vince
    Nov 4, 2019 at 16:40

1 Answer 1


I solved the problem actually.

There were two problems:

  1. Slashes in the paths were not accurate.
  2. I needed to get rid of ".dbf" extension for the output of excel to table conversion tool.
# Excel is input, gdb is output gdb.
excel = r"C:\Users\canerf\Desktop\Assignment_5\excel_files"
gdb = r"C:\Users\canerf\Desktop\Assignment_5\excels.gdb"

for root, dirs, files in os.walk(excel):
    for f in files:
        outname = os.path.join(gdb, os.path.basename(f[:-5]))
        print (outname)
        arcpy.ExcelToTable_conversion(f, outname)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.