AnsweredAssumed Answered

Script to import Excel files

Question asked by Denniska1 on May 31, 2016
Latest reply on May 31, 2016 by bem08c

I am trying to create a script to import a few properly formatted excel files into ArcMap with the Excel to Table conversion tool.

The script is throwing an exception saying "Filed in invalid".

But when I import the same excel files manually in ArcMap, it succeeds without error!

If all the script is doing is passing the files to the conversion tool (that succeeds on its own with every file), why doesn't the script execute? 

Is it because I don't have an exception handling procedure that the Excel to Table conversion tool needs?


Here is the code:


import arcpy

import os


   for file in arcpy.ListFiles("*.xl*"):

           filename = os.path.splitext(file)[0]




Here is the error:

Runtime error  Traceback (most recent call last):   File "<string>", line 3, in <module>   File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\", line 44, in ExcelToTable     raise e ExecuteError:  Traceback (most recent call last):   File "c:\program files (x86)\arcgis\desktop10.3\ArcToolbox\Scripts\", line 252, in <module>     arcpy.GetParameterAsText(2))   File "c:\program files (x86)\arcgis\desktop10.3\ArcToolbox\Scripts\", line 223, in excel_to_table     template=tmp_table)   File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\", line 15306, in CreateTable     raise e ExecuteError: ERROR 999999: Error executing function. The name of the Field is invalid: valid names may contain letters, numbers or underscores. Failed to execute (CreateTable).   Failed to execute (ExcelToTable).