AnsweredAssumed Answered

Simple table to excel conversion in Python

Question asked by pierrejonathan.jp on Aug 13, 2018
Latest reply on Aug 21, 2018 by pierrejonathan.jp

Good day everyone,

 

I've used the table to excel tool in model builder but now I want to have it in a form of a python script. Using the ESRI Table to Excel Help paged and I ended up with this.

 

 

     # Run the Intersect analysis
    Input_Table = arcpy.Intersect_analysis([IntersectFeature, AreaOfInterest], SpecifiedSites, "ALL", "", "INPUT")
   
    # Report a success message   
    arcpy.AddMessage("Intersect analysis made!")
   
    #Process: Export to CSV table
    arcpy.TableToExcel_conversion(Input_Table, wrk+"\Ouput_Excel_File.xls", "NAME", "CODE")
  
    # Report a success message   
    arcpy.AddMessage("Results exported to a Excel file!")

 

The intersect analysis works fine but the conversion failed to execute.  Here's the specific error message:

 

Running script TableToExcel...

Failed script TableToExcel...

怀 

Traceback (most recent call last):

File "c:\program files (x86)\arcgis\desktop10.2\ArcToolbox\Scripts\TableToExcel.py", line 222, in <module>

arcpy.GetParameter(3))

File "c:\program files (x86)\arcgis\desktop10.2\ArcToolbox\Scripts\TableToExcel.py", line 216, in table_to_excel

workbook.save(output)

File "C:\Python27\ArcGIS10.2\lib\site-packages\xlwt\Workbook.py", line 662, in save

doc.save(filename, self.get_biff_data())

File "C:\Python27\ArcGIS10.2\lib\site-packages\xlwt\CompoundDoc.py", line 261, in save

f = open(file_name_or_filelike_obj, 'w+b')

IOError: [Errno 2] No such file or directory: u'C:\\Users\\pierrej\\Desktop\\GISData\\Ouput_Excel_File.xls'

Outcomes