How to copy some rows in a featureclass  to  another feature?

2048
5
08-10-2011 12:38 AM
lmzh
by
New Contributor
I am new to Python and have started to create scripts for copyrows. I am wondering how to copy some rows in a featureclass  to  another featureclass
here is the code,"TERP","RFCP"is the name of featureclass in the code ,"GB" is the fieldname in TERP
import arcgisscripting

gp = arcgisscripting.create(9.3)

gp.workspace = "D:\data\test\1\H45G062061dlg.mdb"
#workspaceslists=gp.listworkspaces("*","access")
#for ws in workspaceslists:
# gp.workspace=ws
gp.toolbox = "management"

query = 'GB = "7201001"'
gp.maketableview(TERP," GB_view", query)

# Copy the table view to a new table
 
gp.copyrows("GB_view", RFCP)



Thanks in advance
Tags (2)
0 Kudos
5 Replies
RDHarles
Occasional Contributor
Here's an example (and the tools you'd use) to copy rows from one table to another:

gp.MakeTableView_management("table1.dbf", "lyrtable")    
gp.SelectLayerByAttribute_management("lyrtable", "New_Selection", '"AREATYP" = 3136')
gp.CopyRows_management("lyrtable", "table2.dbf")
0 Kudos
lmzh
by
New Contributor
"gp.workspace = "D:/data/test/1/H45G062061dlg.mdb" " instead of  "gp.workspace = "D:\data\test\1\H45G062061dlg.mdb"  and   query = "GB = 7201001"  instead of  query = 'GB = "7201001"'   run correctly,but  copying rows  did not append the featureclass but covered
0 Kudos
RDHarles
Occasional Contributor
What error message you getting?

I made a quick mdb and table and ran this script (similar to yours) and it worked fine.

import arcgisscripting
gp = arcgisscripting.create(9.3)

gp.workspace = "C:/junk/db1.mdb"
gp.maketableview("Table1", "t1", "temp = 4")
gp.copyrows("t1", "z1")
0 Kudos
lmzh
by
New Contributor
What error message you getting?

I made a quick mdb and table and ran this script (similar to yours) and it worked fine.

import arcgisscripting
gp = arcgisscripting.create(9.3)

gp.workspace = "C:/junk/db1.mdb"
gp.maketableview("Table1", "t1", "temp = 4")
gp.copyrows("t1", "z1")


my script can run correctly,but I want to append  features that selcleted  into another featureclass ,how to do this ?
0 Kudos
RDHarles
Occasional Contributor
After you gp.copyrows the first time, you can the continue to add to the feature class by using the Append tool.

gp.Append_management("x1", "t1", "NO_TEST")
0 Kudos