# Table to Excel export using python in ArcSDE

1392
4
07-21-2016 02:56 PM
New Contributor III

Hi,

I am wanting to (from Windows 10 desktop) to run a python script that exports the table from feature classes, within a feature dataset, in an ArcSDE environment. I can manually run the script in ArcMap everyday, but this will add to the tasks that I already have. I need the script to run outside of ArcGIS so I can automatically run the script with Scheduled Tasks in Windows.

I have created the connection file and can list feature datasets and classes but I cannot figure out how to use the arcpy "table to excel" tool on the feature datasets within feature classes.

What I have so far:

# Import arcpy module

import arcpy

from arcpy import env

import os

arcpy.env.workspace = "G:\Location_of_Connection.sde_file"

Utility_Pipe = "Utility_pipe_???_Unsure how to point directly at the FC in SDE"

Utility_xls = "Location of Utility Excel\Utility.xls"

# Process: Table To Excel

arcpy.TableToExcel_conversion(Utility_Pipe, Utility_xls, "NAME", "CODE")

print "done"

I using ArcMap 10.3.1 in an enterprise geodatabase on windows 10.

Thanks!

Tags (3)
4 Replies
MVP Esteemed Contributor

If you have done it manually, perhaps you can use the information in the Results window

maybe even exporting to a python snippet

New Contributor III

I looked at that before realizing that by using a python script to run the model itself would reduce the coding headache significantly.
The python script to run the model can be found here http://joelmccune.com/run-models-as-scheduled-tasks/

Regular Contributor

Table to Table (Conversion)

import arcpyfc = r'C:\path\to\your\fc'outtable = r'C:\temp'

arcpy.TableToTable_conversion (fc, outtable, 'outtableFile.dbf')

New Contributor III

I was able to get this to work on local data, but pointing the fc to the specific feature class in the versioned ArcSDE environment was proving troublesome. So I went with the solution I detailed above.

Thanks though