ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for 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
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Table Compare

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

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

  • 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.

  • 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, and 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 which 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

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.

  • 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
(Optional)

These properties will not be compared during comparison.

  • IGNORE_EXTENSION_PROPERTIES —Do not compare extension properties.
  • IGNORE_SUBTYPES —Do not compare subtypes.
  • IGNORE_RELATIONSHIPCLASSES —Do 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_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 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
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.

# 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

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the Data Comparison toolset

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal