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

Table Compare

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Compares two tables or table views and returns the comparison results.

Usage

  • This tool returns messages showing the comparison result. By default, it will stop executing after encountering the first miscompare. To report all differences, check on the Continue Comparison parameter.

  • Table Compare can report differences and similarities with tabular values and field definitions.

  • Multiple sort fields may be specified. Both the Input Base Table and Input Test Table are sorted based on the fields you specify. The first field is sorted, then the second field, and so on, in ascending order. Sorting by a common field in both the base and test table ensures that you are comparing the same row from each input dataset.

  • By default the compare type is set to ALL. This means all properties of the tables being compared will be checked, including such things as field properties and attributes. However, you may choose a different compare type to check only specific properties of the tables being compared.

  • The Ignore Options provide the flexibility to omit properties from the comparison. These properties include extension properties, subtypes, and relationship classes.

  • When omitting fields that are not included in the field count comparison, the field definitions and tabular values for those fields are ignored.

  • Attribute tolerances can only be specified for numeric field types.

  • The Output Compare 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 that can be viewed and used as a table in ArcGIS. For example, this table can be queried to obtain all the ObjectID values for all the rows that are different.

  • When using this tool in Python, you can get the status of this tool using result.getOutput(1). The value will be 'true' when no differences are found and 'false' when differences are detected.

    Learn more about using tools in Python

Syntax

arcpy.management.TableCompare(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. The 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.

  • ALL —Compare all properties. This is the default.
  • ATTRIBUTES_ONLY —Only compare the attributes and their values.
  • SCHEMA_ONLY —Only compare the schema.
String
ignore_options
[ignore_options,...]
(Optional)

These properties will not be compared.

  • IGNORE_EXTENSION_PROPERTIES —Do not compare extension properties.
  • IGNORE_SUBTYPES —Do not compare subtypes.
  • IGNORE_RELATIONSHIPCLASSES —Do not compare relationship classes.
  • IGNORE_FIELDALIAS —Do not compare field aliases.
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_COMPARE —Stop after encountering the first mismatch. This is the default.
  • CONTINUE_COMPARE —Compare other properties after encountering the first mismatch.
Boolean
out_compare_file
(Optional)

This file will contain all similarities and differences between the in_base_table and the in_test_table. This file is a comma-delimited text file that can be viewed and used as a table in ArcGIS.

File

Derived Output

NameExplanationData Type
compare_status

The compare status will be 'true' when no differences are found and 'false' when differences are detected.

Boolean

Code sample

TableCompare example 1 (Python window)

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

import arcpy
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 example 2 (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.

# 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"
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)

Environments

  • Current Workspace

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics

  • An overview of the Data Comparison toolset

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