Table Compare (Data Management)


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



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

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

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

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

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.

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.
[[Field, {Tolerance}],...]

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

Value Table

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


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.

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.


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:
# Description: Compare two dBASE tables and return comparison result.
# Author: ESRI

# import system modules 
import arcpy

    # Set local variables
    base_table= "C:/Workspace/wells.dbf"
    test_table = "C:/Workspace/wells_new.dbf"
    sort_field = "WELL_ID"
    compare_type = "ALL"
    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()
    # Print error message if an error occurs
    print arcpy.GetMessages()


Related Topics

Licensing Information

ArcView: Yes
ArcEditor: Yes
ArcInfo: Yes