import csv
import datetime
import arcgisscripting
gp = arcgisscripting.create(9.3)
# Set workspace.
gp.Workspace = r"C:\Users\Administrator\AppData\Roaming\ESRI\ArcCatalog\MYDB.sde"
dsList = gp.ListDatasets("TARGET_DATASET", "")
fcList = gp.ListFeatureClasses("TARGET_FEATURE_CLASS", "", dsList[0])
# Create Search cursor for feature class.
cur = gp.SearchCursor(fcList[0], '"COUNTRY" = \'CHINA\'')
row = cur.Next()
# Write csv
csv_file = open("C:\\" + datetime.datetime.now().strftime('%Y%m%d') + ".csv", "wb")
writer = csv.writer(csv_file, delimiter=",")
while row:
feat = row.Shape
pnt = feat.GetPart(0)
writer.writerow((row.CITY, str(pnt.x)[1:6], str(pnt.Y)[1:6]))
row = cur.Next()
# Read other csv then append to the newly created csv
other_csv_file = open("D:\\other.csv", 'rt')
try:
reader = csv.reader(other_csv_file)
for row in reader:
writer.writerow(row)
finally:
other_csv_file.close()
csv_file.close()
沒有留言:
發佈留言