Python command to open table

5755
9
Jump to solution
06-17-2015 10:51 PM
SiyangTeo
Occasional Contributor

I have a model that runs a data check with an output table listing the number errors it found. I am wondering if I can complete the the model with a python statement that calls it to open the table.

I know I can just right click and open the attribute table in ArcMap, but I just thought it will be cool to have a really complete model from start to end.

I am using 10.2.2.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
BillDaigle
Occasional Contributor III

Does it need to open it in ArcMap?  Depending on the format of the table, you open it to another program...

from subprocess import Popen
Popen(pathToOutputTable, shell=True)

View solution in original post

9 Replies
JamesCrandall
MVP Frequent Contributor

I don't believe arcpy.mapping provides this capability.

https://www.google.com/?gws_rd=ssl#q=arcpy.mapping+open+table

SiyangTeo
Occasional Contributor

Thanks James, for pointing out to this module. I still have an elementary knowledge of Python usage so this is helpful.

0 Kudos
BillDaigle
Occasional Contributor III

Does it need to open it in ArcMap?  Depending on the format of the table, you open it to another program...

from subprocess import Popen
Popen(pathToOutputTable, shell=True)
SiyangTeo
Occasional Contributor

Great, it works!

Thanks Bill.

0 Kudos
JamesCrandall
MVP Frequent Contributor

This opens an attribute table in ArcGIS?

0 Kudos
DanPatterson_Retired
MVP Emeritus

Not in arcmap...but you can open arcmap...soooo if you coincidently had a project with a table open AND you ran that it would open the project that you direct it to.  You can open any-ish file IF it has a pre-designated file association...you don't need to know the path to the *.exe.  Give it a whirl...limited use and be careful on how you use it with reading the documentation at the python site

0 Kudos
SiyangTeo
Occasional Contributor

What I did was to changed my model to output as a shapefile instead of a feature class, and then use that function to open the .dbf table in Excel.

0 Kudos
JamesCrandall
MVP Frequent Contributor

I read your OP that you were asking how to open an attribute table in ArcGIS but I can see how you simply used that as an example ("right-click to open the table in ArcMap").

There are a number of options.  One is to convert your table to a numpy array with arcpy.da.TableToNumPyArray() and then save the numpy array to a .csv file.  I'd prefer this option over working with .dbf's.  Then issue Bills approach to open that file directly.

ArcGIS Help 10.1

0 Kudos
BillDaigle
Occasional Contributor III

I usually work with csv's as well.  No reason to create a shape file if you don't need to. 

0 Kudos