Is a table in ArcMap a layer or a tableview. I want to be able to feed a table into an UpdateCursor via a toolbox script. If my table has a definition query on it how do I check for that with python?


A table is a table. Look at the Dataset properties docs. Here is a describe on a Excel sheet:

>>> import arcpy
>>> desc = arcpy.Describe("Sheet1$")
>>> print desc.datasetType

And here is how you get the definition query, again with a describe:

>>> desc = arcpy.Describe("Sheet1$")
>>> dq = desc.whereClause
>>> dq
u"`F2` = 'Downloaded data'"

EDIT: blah238 is correct:

>>> desc = arcpy.Describe("Sheet1$")
>>> print desc.dataType

So, evidently a table is seen as a File and not a Dataset? The help topic on File properties isn't very helpful.

  • 2
    This is incorrect actually. A standalone table in ArcMap's table of contents is actually a table view, just like a feature layer. You can reference them by name instead of full path, and they can have definition queries, as you demonstrated. Try desc.dataType and see what that says. – blah238 Mar 2 '12 at 2:33
  • 1
    Regarding your latest edit: A dataset is a broad term that can include many data types (see the list on the help page for it). The .xls file itself is described as a File, but the worksheets within are Tables, and when you add them to your ArcMap TOC, they become Table Views. Since an Excel workbook (.xls or .xlsx file) can contain many tables, I like to think of them as file-based databases. The way you specify the full path to an Excel worksheet is <path to .xls file>\<sheet name>$ – blah238 Jun 22 '12 at 1:46

Thanks @blah238. I found this arcpy.mapping.ListTableViews(mxd, "", df): which is what I was looking for here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.