Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Why does ArcPy Excel To Table give AttributeError: 'module' object has no attribute? [closed]

$
0
0

I’m trying to import an excel workbook using arcpy. ExcelToTable, but I get the following traceback:

ERROR

updateParameters Execution Error: Runtime error Traceback (most recent call last): 
File "c:program files (x86)arcgisdesktop10.2ArcToolboxToolboxesConversion 
Tools.tbx#ExcelToTable_conversion.UpdateParameters.py", line 4, in File 
"c:program files (x86)arcgisdesktop10.2ArcToolboxToolboxesConversion Tools.tbx
#ExcelToTable_conversion.UpdateParameters.py", 
line 40, in updateParameters AttributeError: 'module' object has no attribute 
'get_sheet_names' 

I have imported arcpy, have I missed something else?

EDIT: Here’s my code:

from win32com.client import Dispatch
import arcpy, os
from arcpy import env

arcpy.env.workspace = "C:\Users\Ant\Documents\ArcGIS\ITN.gdb"
env.overwriteOutput = True

x = 1
with arcpy.da.UpdateCursor("Sites",["SizeScore","SizeWt","UPRNScore","UPRNWt"]) as cursor:
for row in cursor:
    SQL = "FID = {0}".format(x)
    arcpy.MakeFeatureLayer_management("Sites","Siteslyr",SQL)
    arcpy.TableToExcel_conversion("Siteslyr","C:\Sites.xls")
    def RunExcelMacro(name):
        myExcel = Dispatch('Excel.Application')
        myExcel.Visible = 0
        myExcel.Workbooks.Add('c:\Data\UpdateScores.xlsm')
        myExcel.Run(name)
        myExcel.DisplayAlerts = 0
        myExcel.Quit()
    if __name__ == "__main__":
        RunExcelMacro('MacroEnableDBF')        
    def RunExcelMacro(name):
        myExcel = Dispatch('Excel.Application')
        myExcel.Visible = 0
        myExcel.Workbooks.Add('c:\Data\UpdateScores.xlsm')
        myExcel.Run(name)
        myExcel.DisplayAlerts = 0
        myExcel.Quit()       
    if __name__ == "__main__":
        RunExcelMacro('AppendScores2')
    arcpy.ExcelToTable_conversion("C:\Sitescores.xls", "Carescores")
    with arcpy.da.SearchCursor("Carescores", fields) as curs:
        for rows in curs:
            row[0] = rows[0]
            row[1] = rows[1]
            row[2] = rows[2]
            row[3] = rows[3]
            cursor.updateRow(row)
    x = x + 1

Viewing all articles
Browse latest Browse all 767

Trending Articles