ListTableViews
Zusammenfassung
Returns a Python list of TableView objects that exist within a map document (.mxd).
Beschreibung
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
Parameter | Erläuterung | Datentyp |
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. (Der Standardwert ist None) | String |
data_frame |
A variable that references a DataFrame object. (Der Standardwert ist None) | DataFrame |
Datentyp | Erläuterung |
TableView |
A Python list of TableView objects. |
Codebeispiel
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