Script & Tool之Appenddata
# -*- coding:gb2312 -*-
#Author:tony.gu email: tony.gu@gisinfo.com
#function: append data from one workspace to another
#目前只支持shp到数据库中的某个数据集
import arcpy,os
import fnmatch
from arcpy import env
in_path=arcpy.GetParameterAsText(0)
#in_path="D:\\file\\dd"
#workspace="Database Connections\\gisinfo116.sde\\GISINFO.bj"
workspace=arcpy.GetParameterAsText(1)
arcpy.env.workspace=workspace
#def list(in_path):
for file in os.walk(in_path):
for f2 in file[2]:
if f2!="":
fullFile=file[0]+"\\"+f2
print fullFile
if fnmatch.fnmatch(fullFile,"*.shp"):
leng=len(fullFile.split("\\"))-1
print leng
FileName=fullFile.split("\\")[leng].replace(".shp","")
print FileName
FeatureClasses=arcpy.ListFeatureClasses()
for featureclass in FeatureClasses:
print featureclass
FullFeature=workspace+"\\"+featureclass
print FullFeature
if featureclass.find(FileName)>0:
arcpy.Append_management(fullFile,FullFeature)
#list(in_path)
转载自:https://blog.csdn.net/gisinfo/article/details/6712384