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

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Copy Rows

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

Summary

Copies the rows of a table, table view, feature class, feature layer, or raster with attribute table to a new geodatabase, .csv, .txt, or .dbf table. If the table or feature layer has a selection, only the selected rows are copied to the output table.

Usage

  • This tool supports the following table formats as input:

    • Geodatabase
    • dBASE (.dbf)
    • Comma-separated values (.csv or .txt)
    • Microsoft Excel worksheets (.xls or .xlsx)
    • INFO
    • VPF
    • OLE database
    • 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 the input file contains spaces or special characters.

    Learn more about table formats supported in ArcGIS

  • All rows are copied if the input is a feature class or table. If the input rows are from a layer or table view that has a selection, only the selected features or rows will be used.

  • If the input rows are a feature class, only the attributes, and not the geometry, are copied to the output table.

  • To add or append the copied rows to an existing table, use the Append tool.

Syntax

CopyRows(in_rows, out_table, {config_keyword})
ParameterExplanationData Type
in_rows

The input rows to be copied to a new table.

Table View; Raster Layer
out_table

The table that will be created and to which rows from the input will be copied.

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

Table
config_keyword
(Optional)

Specifies the default storage parameters for an enterprise geodatabase.

String

Code sample

CopyRows example 1 (Python window)

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

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

The following stand-alone script demonstrates how to use CopyRows to copy the tables in a folder to a file geodatabase.

# Description: Convert all dBASE tables in a folder to geodatabase tables
# Requirement: os module

# Import system modules
import arcpy
import os
 
# Set environment settings
arcpy.env.workspace = "C:/data"
 
# Set local variables
outWorkspace = "c:/output/output.gdb"
 
# Use ListTables to generate a list of dBASE tables in the
#  workspace shown above.
tableList = arcpy.ListTables()
 
# Execute CopyRows for each input table
for dbaseTable in tableList:
    # Determine the new output feature class path and name
    outTable = os.path.join(outWorkspace, os.path.splitext(dbaseTable)[0])
    arcpy.CopyRows_management(dbaseTable, outTable)

Environments

  • Current Workspace
  • Output CONFIG Keyword
  • Maintain Attachments
  • Scratch Workspace
  • Extent

Licensing information

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

Related topics

  • An overview of the Table toolset

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

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

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2019 Esri. | Privacy | Legal