Table to Table (Conversion)
Converts an input table to a dBASE or geodatabase table.
This tool supports the following table formats as input:
- dBASE (.dbf)
- Comma Separate Value (.csv)
- tab delimited text (.txt)
- Microsoft Excel worksheets (.xls or .xlsx)
- OLE database
- personal, file, or SDE geodatabase
- in-memory table views
For file input (.csv or .txt), 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 you will receive an error if the first row of input file contains spaces or special characters.
This tool can convert input tables to dBASE (.dbf), geodatabase (personal, file, or SDE), or INFO tables.
This tool can be used to export an ArcGIS table to a dBASE table (.dbf) that can be read and edited in Microsoft Excel.
All fields in the output table and the contents of those fields can be controlled using this tool's Field Map controls.
If the input table is a table view with a selection, only selected rows will be transferred to the output table.
When converting geodatabase data that has attribute domains to a shapefile, dBase table, or coverage, both the domain codes and domain descriptions will be included in the output. The domain descriptions will be in a new field named after the domain field, with _DESC appended to the end of the field name.
The Configuration Keyword parameter specifies the default storage parameters (configurations) for geodatabases in a relational database management system (RDBMS). This setting is applicable only when using SDE geodatabase tables. For more on configuration keyword, see CONFIG keyword.
The input table to be converted to a new table.
|Table View; Raster Layer|
The destination where the output table will be written.
The name of the output table.
If the Output Location is a folder, convert the Input Rows to a dBASE table by specifying a name with the extension .dbf, or convert the Input Rows to a INFO table by specifying a name with no extension. If the Output Location is a geodatabase, convert the Input Rows to a geodatabase table by specifying a name with no extension.
An SQL expression used to select a subset of records. The syntax for the expression differs slightly depending on the data source. For example, if you're querying file or ArcSDE geodatabases, shapefiles, coverages, or dBASE or INFO tables, enclose field names in double quotes:
If you're querying personal geodatabases, enclose fields in square brackets:
In Python, strings are enclosed in matching single or double quotes. To create a string that contains quotes (as is common with a WHERE clause in SQL expressions), you can escape the quotes (using a backslash) or triple quote the string. For example, if the intended WHERE clause is
"CITY_NAME" = 'Chicago'
you could enclose the entire string in double quotes, then escape the interior double quotes like this:
" \"CITY_NAME\" = 'Chicago' "
Or you could enclose the entire string in single quotes, then escape the interior single quotes like this:
' "CITY_NAME" = \'Chicago\' '
Or you could enclose the entire string in triple quotes without escaping:
""" "CITY_NAME" = 'Chicago' """
For more information on SQL syntax and how it differs between data sources, see the help topic SQL reference for query expressions used in ArcGIS.
The fields and field contents chosen from the input table. You can add, rename, or delete output fields as well as set properties such as data type and merge rule.
Merge rules allow you to specify how values from two or more input fields are merged into a single output value. There are several merge rules that you can use:
Specifies the default storage parameters (configurations) for geodatabases in a relational database management system (RDBMS). This setting is applicable only when using SDE geodatabase tables.
ArcSDE configuration keywords are set by the database administrator.
The following Python window script demonstrates how to use the TableToTable tool in immediate mode.
import arcpy from arcpy import env env.workspace = "C:/data" arcpy.TableToTable_conversion("vegtable.dbf", "C:/output/output.gdb", "vegtable")
The following stand-alone script demonstrates how to use the TableToTable tool.
# Name: TableToTable_Example2.py # Description: Use TableToTable with an expression to create a subset # of the original table. # Author: ESRI # Import system modules import arcpy from arcpy import env # Set environment settings 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(env.workspace, "VEG_TYPE") + " = 'Estuarine'" # Execute TableToTable arcpy.TableToTable_conversion(inTable, outLocation, outTable, expression)