python 处理arcgis gdb文
发布时间:2019-07-13 11:39:20编辑:auto阅读(1582)
import arcpy
from arcpy import env
import os
import types
fc = 'D:/demo.gdb/test' # file location .
fields = ["Id", "name", "descr"] # you table columuns .
print '+++++++++++++++++++++++++++++'
with arcpy.da.SearchCursor(fc, fields) as cursor:
f = file('D:/demo.txt', 'w') # open for 'w'riting
for row in cursor:
str = "{0}, {1}, {2}".format(row[0], row[1], row[2])
#print("{0}, {1}, {2}".format(row[0], row[1], row[2]))
print 'The contents is :',str
f.write(str) # write text to file
f.write('\n');
# close the file
f.close()
#print out the content of this text.
f = file('D:/demo.txt')
# if no mode is specified, 'r'ead mode is assumed by default
while True:
line = f.readline()
if len(line) == 0: # Zero length indicates EOF
break
print line,
# Notice comma to avoid automatic newline added by Python
f.close() # close the file
关键字: