Monday, September 16, 2013

Table to Excel (10.2 Arcpy)

Table to excel is a great tool for converting your spatial data into an excel spreadsheet.  In the past, before 10.2, you would have to use a 3rd party module like Python Excel in order to convert your data to and from ArcGIS tables to excel spreadsheets.

It should be noted that this only support the MS Excel 5.0/95 format (.xls) file type.

The syntax and use is pretty simple for this tool, it has 4 inputs, the table path (string), out path (string), use field alias (Boolean and optional), and use domain and sub-type description (Boolean and optional).  Let's dive into an example:

import arcpy
import os
if __name__ == '__main__':
    table = r"c:\temp\scratch.gdb\StarbucksAddresses"
    out_excel = r"c:\temp\starbucks.xls"
    if os.path.isfile(out_excel):
    arcpy.TableToExcel_conversion(table, out_excel)

All we have done here is taken the simplest example and convert my list of Starbucks locations and converted to an excel spreadsheet so I can now use it in excel.


ArcGIS Tool help link -


Anonymous said...

Andrew I dont know mate. I dont get your posts. I spent the last 2 hours trawling through py script to C++ to many areas of intrigue. That isnt what a blog is for, your information is well JUST TO useful.
But on a side note I visit LOTS of blogs and *kicking a stone on the ground like a 10 year old*...yours is by far the best. I personally appreciate the information and time your spending on this.

Agustin said...

Hi Andrew, which Python IDE do you prefer for ArcGIS scripting and Add-ins? Thanks man.

Andrew said...

Thank you for the comments!

Andrew said...

I prefer Wing IDE for python development.

For a free option, try PyScipter or PyDev.

Hope this helps.