TableView

Zusammenfassung

Provides access to basic table properties

Beschreibung

The TableView object references a stand-alone table within the ArcMap table of contents and provides access to a table's name, data source, and definition query properties. The ListTableViews function returns a Python list of TableView objects. It is necessary to then iterate through each item in the list or specify an index number to reference a specific TableView object.

Tables can be searched within an entire map document or within a specific data frame. Wildcards can also be used to limit the search.

A definition query will not work for all workspaces. It is important to use the correct SQL syntax when working with different workspaces. For example, file geodatabases and shapefiles have double quotes around a field name (for example, "field_name"), personal geodatabases have brackets (for example, [field_name]), and SDE connections don't have any special characters (for example, field_name). For more information on updating workspaces and data sources in a map document or layer file, please refer to the Updating and Fixing Data Sources with arcpy.mapping help topic.

Eigenschaften

EigenschaftErläuterungDatentyp
datasetName
(Nur lesen)

Returns the name of the table's dataset the way it appears in the workspace, not in the table of contents.

String
dataSource
(Nur lesen)

Returns table's data source path.

String
definitionQuery
(Nur lesen)

Provides the ability to get or set a tables's definition query.

String
name
(Lesen und schreiben)

Provides the ability to set or get the name of a table the way it would appear in the ArcMap table of contents. Spaces can be included.

String
workspacePath
(Nur lesen)

Returns a path to the table's workspace or connection file.

String

Methodenübersicht

MethodeErläuterung
findAndReplaceWorkspacePath (find_workspace_path, replace_workspace_path, {validate})

Replaces a table's workspace with a new workspace path

replaceDataSource (workspace_path, workspace_type, dataset_name, {validate})

Replaces a table's data source in a map document (.mxd); also provides the ability to switch workspace types (for example, replace a file geodatabase workspace with an SDE workspace).

Methoden

findAndReplaceWorkspacePath (find_workspace_path, replace_workspace_path, {validate})
ParameterErläuterungDatentyp
find_workspace_path

A string that represents the workspace path or connection file you want to find. If an empty string is passed, then all workspace paths will be replaced with the replace_workspace_path parameter depending on the value of the validate parameter.

String
replace_workspace_path

A string that represents the workspace path or connection file you want to use to replace.

String
validate

If set to True, the workspace will only be updated if the replace_workspace_path value is a valid workspace. If it is not valid, the workspace will not be replaced. If set to False, the method will set the workspace to match the replace_workspace_path, regardless of a valid match. In this case, if a match does not exist, then the table's data source would be broken.

(Der Standardwert ist True)

Boolean

For more detailed discussion, parameter information, scenarios, and code samples, please refer to the Updating and fixing data sources help topic.

replaceDataSource (workspace_path, workspace_type, dataset_name, {validate})
ParameterErläuterungDatentyp
workspace_path

A string that includes the workspace path to the new data or connection file.

String
workspace_type

A string keyword that represents the workspace type of the new data.

  • ACCESS_WORKSPACE A personal geodatabase or Access workspace
  • ARCINFO_WORKSPACE An ArcInfo coverage workspace
  • CAD_WORKSPACEA CAD file workspace
  • EXCEL_WORKSPACEAn Excel file workspace
  • FILEGDB_WORKSPACEA file geodatabase workspace
  • NONEUsed to skip the parameter
  • OLEDB_WORKSPACEAn OLE database workspace
  • PCCOVERAGE_WORKSPACEA PC ARC/INFO Coverage workspace
  • RASTER_WORKSPACEA raster workspace
  • SDE_WORKSPACEAn SDE geodatabase workspace
  • SHAPEFILE_WORKSPACEA shapefile workspace
  • TEXT_WORKSPACEA text file workspace
  • TIN_WORKSPACEA TIN workspace
  • VPF_WORKSPACEA VPF workspace
String
dataset_name

A string that represents the name of the table the way it appears in the new workspace (not the name of the table in the table of contents).

String
validate

If set to True, a workspace will only be updated if the workspace_path value is a valid workspace. If it is not valid, the workspace will not be replaced. If set to False, the method will set the workspace to match the workspace_path, regardless of a valid match. In this case, if a match does not exist, then the data source would be broken.

(Der Standardwert ist True)

Boolean

For more detailed discussion, parameter information, scenarios, and code samples, please refer to the Updating and Fixing Data Sources help topic.

Codebeispiel

TableView example

The following script will find a table called Customers in a data frame named Transportation and will set its definition query.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0]
for table in arcpy.mapping.ListTableViews(mxd, "", df):
    if table.name.lower() == "trafficaccidents":
        table.definitionQuery = "\"age\" >= 18"
mxd.save()
del mxd

7/10/2012