ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS 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
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

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

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal