ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

ListTableViews

  • Summary
  • Discussion
  • Syntax
  • Code Sample

Summary

Returns a Python list of TableView objects that exist within a map document (.mxd).

Discussion

ListTableViews always returns a list object even if only one table is returned. In order to return a TableView object, an index value must be used on the list (e.g., aTable = arcpy.mapping.ListTableViews(mxd)[0]). For loops on a list provide an easy mechanism to iterate through each item in the list (e.g., for aTable in arcpy.mapping.ListTableViews(mxd):).

Wildcards are used on the name property and are not case sensitive. A wildcard string of "so*" will return a layer with a name Soils. Wildcards can be skipped in the scripting syntax simply by passing an empty string (""), an asterisk (*), or entering wildcard=None, or nothing at all if it is the last optional parameter in the syntax.

It is possible that there might be tables in a map document that have the same name. If that is the case, then other properties may need to be used to isolate a specific layer. Properties such as a tables's datasource or definitionQuery could be used to do this. It is ideal that all tables in a map document be uniquely named.

Syntax

ListTableViews (map_document, {wildcard}, {data_frame})
ParameterExplanationData Type
map_document

A variable that references a MapDocument object.

MapDocument
wildcard

A combination of asterisks (*) and characters can be used to help limit the results.

(The default value is None)

String
data_frame

A variable that references a DataFrame object.

(The default value is None)

DataFrame

Return Value

Data TypeExplanation
TableView

A Python list of TableView objects.

Code Sample

ListTableViews example

The following script finds a table called TrafficAccidents in a data frame named Transportation and sets a definition query.

import arcpy
mxd = arcpy.mapping.MapDocument(r"c:\project\project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0]
table = arcpy.mapping.ListTableViews(mxd, "TrafficAccidents", df)[0]
table.definitionQuery = "[Accidents] > 5"
mxd.save()
del mxd
Feedback on this topic?

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal