问题遇到的现象和发生背景
ArcMAP 自己写的脚本导出字段属性结构,导出为 *.csv 文件,运行成功了,唯一不好的是程序结束,ArcMAP自动把生成的*.csv文件给添加到数据内容列表里了。
用代码块功能插入代码,请勿粘贴截图
#coding=gbk
import arcpy
import csv
import codecs
fc = arcpy.GetParameterAsText(0)
filename = arcpy.GetParameterAsText(1)
fb = arcpy.ListFields(fc)
arcpy.AddMessage("count:{}".format(len(fc)))
arcpy.AddMessage("out filename:{}".format(filename))
# ["字段名\t字段别名\t字段类型\t宽度\t精度\t小数点"]
shuxing = [u"字段名\t,字段别名\t,字段类型\t,宽度\t,精度\t,小数点\n"]
x = 0
y = 0
for i in fb:
if i.type == "String":
shuxing.append(u"{}\t,{}\t,{}\t,{}\t,{}\t,{}\n".format(i.name, i.aliasName, i.type, i.length, "", ""))
elif i.type in ["Single", "Double"]:
shuxing.append(u"{}\t,{}\t,{}\t,{}\t,{}\t,{}\n".format(i.name, i.aliasName, i.type, "", i.precision, "{}".format(i.scale)))
elif i.type in [u"SmallInteger", "Integer"]:
shuxing.append(u"{}\t,{}\t,{}\t,{}\t,{}\t,{}\n".format(i.name, i.aliasName, i.type, "", "{}".format(i.length), ""))
elif i.type == "Date":
shuxing.append(u"{}\t,{}\t,{}\t,{}\t,{}\t,{}\n".format(i.name, i.aliasName, i.type, "", "", ""))
else:
pass
with open(filename, "wb") as f:
arcpy.AddMessage("start writer file *.csv")
b_writer = csv.writer(f)
for i in shuxing:
f.write(i.encode("gbk"))
arcpy.AddMessage("+++++++++++++++++++++++")
运行结果及报错内容
没有错误
我的解答思路和尝试过的方法
本人毫无办法
我想要达到的结果
想让ArcGIS 在脚本结束后,不要把生成的*.csv文件添加到内容列里。