Table Compare (Data Management)

License Level:BasicStandardAdvanced

Summary

Compares two tables or table views and returns the comparison results. This tool can report differences and similarities with tabular values and field definitions.

Usage

Syntax

TableCompare_management (in_base_table, in_test_table, sort_field, {compare_type}, {ignore_options}, {attribute_tolerances}, {omit_field}, {continue_compare}, {out_compare_file})
ParameterExplanationData Type
in_base_table

The Input Base Table is compared with the Input Test Table. The Input Base Table refers to tabular data that you have declared valid. This base data has the correct field definitions and attribute values.

Table View; Raster Layer
in_test_table

The Input Test Table is compared against the Input Base Table. The Input Test Table refers to data that you have made changes to by editing or compiling new fields, new records, or new attribute values.

Table View ; Raster Layer
sort_field
[sort_field,...]

The field or fields used to sort records in the Input Base Table and the Input Test Table. The records are sorted in ascending order. Sorting by a common field in both the Input Base Table and the Input Test Table ensures that you are comparing the same row from each input dataset.

Value Table
compare_type
(Optional)

The comparison type. ALL is the default. The default will compare all properties of the tables being compared.

  • ALLCompare all properties. This is the default.
  • ATTRIBUTES_ONLYOnly compare the attributes and their values.
  • SCHEMA_ONLYOnly compare the schema.
String
ignore_options
(Optional)

These properties will not be compared during comparison.

  • IGNORE_EXTENSION_PROPERTIESDo not compare extension properties.
  • IGNORE_SUBTYPESDo not compare subtypes.
  • IGNORE_RELATIONSHIPCLASSESDo not compare Relationship classes.
String
attribute_tolerances
[[Field, {Tolerance}],...]
(Optional)

The numeric value that determines the range in which attribute values are considered equal. This only applies to numeric field types.

Value Table
omit_field
[omit_field,...]
(Optional)

The field or fields that will be omitted during comparison. The field definitions and the tabular values for these fields will be ignored.

String
continue_compare
(Optional)

Indicates whether to compare all properties after encountering the first mismatch.

  • NO_CONTINUE_COMPAREStop after encountering the first mismatch. This is the default.
  • CONTINUE_COMPARECompare other properties after encountering the first mismatch.
Boolean
out_compare_file
(Optional)

This file will contain all similarities and differences between the Input Base Table and the Input Test Table. This file is a comma-delimited text file which can be viewed and used as a table in ArcGIS.

File

Code Sample

TableCompare Example (Python Window)

The following Python window script demonstrates how to use the TableCompare function in immediate mode.

import arcpy
from arcpy import env
arcpy.TableCompare_management(r'c:\Workspace\wells.dbf', r'c:\Workspace\wells_new.dbf', 'WELL_ID', 'ALL', 'IGNORE_EXTENSION_PROPERTIES', 'WELL_DEPTH 0.001', '#', 'CONTINUE_COMPARE', r'C:\Workspace\well_compare.txt' )
TableCompare tool example (stand-alone script)

Example of how to use the TableCompare tool in a stand-alone script.

# Name: TableCompare.py
# Description: Compare two dBASE tables and return comparison result.
# Author: ESRI

# import system modules 
import arcpy

try:
    # Set local variables
    base_table= "C:/Workspace/wells.dbf"
    test_table = "C:/Workspace/wells_new.dbf"
    sort_field = "WELL_ID"
    compare_type = "ALL"
    ignore_option = "IGNORE_EXTENSION_PROPERTIES"
    attribute_tolerance = "WELL_DEPTH 0.001"
    omit_field = "#"
    continue_compare = "CONTINUE_COMPARE"
    compare_file = "C:/Workspace/well_compare.txt"
 
    # Process: FeatureCompare
    compare_result = arcpy.TableCompare_management(base_table, test_table, sort_field, compare_type, ignore_option, attribute_tolerance, omit_field, continue_compare, compare_file)
    print compare_result
    print arcpy.GetMessages()
 
except:
    # Print error message if an error occurs
    print arcpy.GetMessages()

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
11/18/2013