Hi all
I tried to convert excel sheets to table. I did the folowing:
the problem that I got a message 000732 that imput table table .....\file.xlsx\'ATL...$' does not exist or not supported (makeTableView).
the list (Listxls) is well populated. Moreover, I tried the same work at home and it work fine. I really don't know what happen?
Any help please?
By the way, I hve lot of trouble to use this webside. I can't copy/paste anything. My interface is :
Thanks in advance
This happens when you run a program a second time and you don't use "arcpy.env.overwriteOutput = True". If this a repeat add the line of code and rerun, I would suggest if this is not a test environment meaning you don't need the data in the geodatabase, I would make a back up copy.
When using TableToTable_conversion() from Excel to GDB, you need to specify the sheet name suffixed with a $. Something like C:/temp/MyExcelFile.xlsx/mySheetName$
Using the Esri code samples in the Excel To Table link provided by Rebecca Strauch, GISP, you can use the xlrd module for reading the sheets in an Excel file.
import os import xlrd import arcpy def main(): # Local variables in_excel = r"C:\temp\MyExcelFile.xlsx" out_gdb = r"C:\temp\MyGeodatabase.gdb" # Read Sheets in Excel Workbook with xlrd.open_workbook(in_excel) as workbook: sheets = [sheet.name for sheet in workbook.sheets()] # Export each sheet to geodatabase table for sheet in sheets: in_rows = os.path.join(in_excel,str(sheet)+"$") ## The out_name is based on the input excel file name ## an underscore (_) separator followed by the sheet name baseName = os.path.basename(in_excel) out_name = arcpy.ValidateTableName( "{0}_{1}".format(os.path.splitext(baseName)[0], sheet), out_gdb ) arcpy.TableToTable_conversion(in_rows, out_gdb, out_name,) print arcpy.GetMessages(), "\n" if __name__ == '__main__': main()
Said, as a side note on the copy-paste in Geonet, have you seen Posting Code blocks in the new GeoNet ? Main things to remember is the "advanced editor" tab won't show if you are replying within you Geonet inbox....make sure to right-click on the header/title of you question and "open in another tab" .... Opening from you system inbox may work to.
my opologies if you had already seen that post....posting code isn't always consistent.
As another approach, for work with pre-10.2, you might find the Excel and CSV conversion toolbox download from Esri useful: similar tools to what's included in 10.2, plus a csv to table tool.
http://www.arcgis.com/home/item.html?id=f3d91b8f852042e289e09a7ec8342431