Table To Table (Conversion)

Summary

Exports the rows of a table to a different table.

Legacy:

This is a deprecated tool. This functionality has been replaced by the Export Table tool.

Usage

  • The tool copies the rows of a table, table view, feature class, feature layer, delimited file, or raster with an attribute table to a new geodatabase or dBASE table or a delimited file.

  • This tool supports the following table formats as input:

    • Geodatabase
    • dBASE (.dbf)
    • Microsoft Excel worksheets (.xls and .xlsx)
    • Memory-based tables
    • Delimited files
      • Comma-delimited files (.csv, .txt, and .asc)
      • Tab-delimited files (.tsv and .tab)
      • Pipe-delimited files (.psv)

    For delimited files, the first row of the input file is used as the field names on the output table. Field names cannot contain spaces or special characters (such as $ or *), and an error will occur if the first row of the input file contains spaces or special characters.

  • If the Output Location parameter value is not a geodatabase, BLOB or raster fields will not be included. GlobalID fields will be converted to text fields.

  • The tool can be used to output a delimited file by adding one of the following file extensions to the output name in a folder workspace:

    • Comma-delimited files (.csv, .txt, or .asc)
    • Tab-delimited files (.tsv or .tab)
    • Pipe-delimited files (.psv)

  • Use the Field Map parameter to manage the fields and their content in the output dataset.

    • Add and remove fields from the fields list, reorder the fields list, and rename fields.
    • The default data type of an output field is the same as the data type of the first input field (of that name) it encounters. You can change the data type to another valid data type.
    • Use an action to determine how values from one or multiple input fields will be merged into a single output field. The available actions are First, Last, Concatenate, Sum, Mean, Median, Mode, Minimum, Maximum, Standard Deviation, and Count.
    • When using the Concatenate action, you can specify a delimiter such as a comma or other characters. Click the start of the Delimiter text box to add the delimiter characters.
    • Standard Deviation is not a valid option for single input values.
    • Use the Slice Text button on text source fields to choose which characters from an input value will be extracted to the output field. To access the Slice Text button, hover over a text field in the input fields list; then specify the start and end character positions.
    • Fields can also be mapped using Python scripts.

  • When converting geodatabase data that has subtypes or domains to a dBASE table, both the subtype and domain codes and descriptions can be included in the output. Use the Transfer field domain descriptions geoprocessing environment to do this. By default, only domain and subtype codes will be included in the output, not descriptions.

    Note:

    Converting to a dBASE table with subtype and domain descriptions may take more time (slower performance) than without descriptions. If subtype and domain descriptions are not required in the dBASE table output, leave the Transfer field domain descriptions environment unchecked for best performance.

Parameters

LabelExplanationData Type
Input Rows

The input table that will be exported to a new table.

Table View; Raster Layer
Output Location

The destination where the output table will be written.

Workspace
Output Name

The name of the output table.

If the output location is a folder, include an extension such as .csv, .txt, or .dbf to export the table to that format. If the output location is a geodatabase, do not specify an extension.

String
Expression
(Optional)

An SQL expression that will be used to select a subset of records.

SQL Expression
Field Map
(Optional)

The fields that will be transferred to the output dataset with their respective properties and source fields. By default, the output includes all fields from the input dataset.

Use the field map to add, delete, rename, and reorder fields, as well as change other field properties.

The field map can also be used to combine values from two or more input fields into a single output field.

Field Mappings
Config Keyword
(Optional)

Specifies the default storage parameters (configurations) for geodatabases in a relational database management system (RDBMS). This setting is applicable only when using enterprise geodatabase tables.

Configuration keywords are set by the database administrator.

String

Derived Output

LabelExplanationData Type
Output Table

The output table.

Table

arcpy.conversion.TableToTable(in_rows, out_path, out_name, {where_clause}, {field_mapping}, {config_keyword})
NameExplanationData Type
in_rows

The input table that will be exported to a new table.

Table View; Raster Layer
out_path

The destination where the output table will be written.

Workspace
out_name

The name of the output table.

If the output location is a folder, include an extension such as .csv, .txt, or .dbf to export the table to that format. If the output location is a geodatabase, do not specify an extension.

String
where_clause
(Optional)

An SQL expression that will be used to select a subset of records.

SQL Expression
field_mapping
(Optional)

The fields that will be transferred to the output dataset with their respective properties and source fields. By default, the output includes all fields from the input dataset.

Use the field map to add, delete, rename, and reorder fields, as well as change other field properties.

The field map can also be used to combine values from two or more input fields into a single output field.

In Python, use the FieldMappings class to define this parameter.

Field Mappings
config_keyword
(Optional)

Specifies the default storage parameters (configurations) for geodatabases in a relational database management system (RDBMS). This setting is applicable only when using enterprise geodatabase tables.

Configuration keywords are set by the database administrator.

String

Derived Output

NameExplanationData Type
out_table

The output table.

Table

Code sample

TableToTable example 1 (Python window)

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

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.conversion.TableToTable("vegtable.dbf", "C:/output/output.gdb", "vegtable")
TableToTable example 2 (stand-alone script)

The following stand-alone script demonstrates how to use the TableToTable function.

# Description: Use TableToTable with an expression to create a subset
#  of the original table.
 
# Import system modules
import arcpy
 
# Set environment settings
arcpy.env.workspace = "C:/data"
 
# Set local variables
inTable = "vegtable.dbf"
outLocation = "C:/output/output.gdb"
outTable = "estuarine"

# Set the expression, with help from the AddFieldDelimiters function, to select 
# the appropriate field delimiters for the data type
expression = arcpy.AddFieldDelimiters(arcpy.env.workspace, "VEG_TYPE") + " = 'Estuarine'"
 
# Run TableToTable
arcpy.conversion.TableToTable(inTable, outLocation, outTable, expression)