注释一段GP工具中Python脚本(读取表中字段信息)
2009-05-20 11:06
549 查看
# ---------------------------------------------------------------------------
# Iterate Field Value.py
# ---------------------------------------------------------------------------
# Import system modules
import sys, string, os, arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create()
# Set the parameters.
# Input feature class or table for which the value has to be read from a field
inputTable = gp.GetParameterAsText(0)
if (inputTable == ''):
gp.AddError("No input table provided")
raise "No input table provided"
# The desired field for which the values will be read
inputField = gp.GetParameterAsText(1) #你要检索的字段 手动输入
if (inputField == ''):
gp.AddError("No input field provided")
raise "No input field provided"
# Setting value to increment the iteration number for next row in the table
index = int(gp.GetParameterAsText(2))# 让你的迭代次数和对表的索引号一致
# Insert Search Cursor
value = "0" #初始化输出值
bContinue = "false"
currentRow = 0
cur = gp.SearchCursor(inputTable) #开始扫描表
row = cur.Next()# 跳过表头 进入下一行
while row:
if (index == currentRow):#判断行号和索引是否一致
value = row.getValue(inputField)#获取该行 该字段中的值
bContinue = "true" # 把进行一下步的预处理设为真
break
row = cur.Next()
currentRow = currentRow + 1 #开始进入下次循环
del cur
gp.SetParameterAsText(3, str(value))
gp.SetParameterAsText(4, str(bContinue))# 输出
# Iterate Field Value.py
# ---------------------------------------------------------------------------
# Import system modules
import sys, string, os, arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create()
# Set the parameters.
# Input feature class or table for which the value has to be read from a field
inputTable = gp.GetParameterAsText(0)
if (inputTable == ''):
gp.AddError("No input table provided")
raise "No input table provided"
# The desired field for which the values will be read
inputField = gp.GetParameterAsText(1) #你要检索的字段 手动输入
if (inputField == ''):
gp.AddError("No input field provided")
raise "No input field provided"
# Setting value to increment the iteration number for next row in the table
index = int(gp.GetParameterAsText(2))# 让你的迭代次数和对表的索引号一致
# Insert Search Cursor
value = "0" #初始化输出值
bContinue = "false"
currentRow = 0
cur = gp.SearchCursor(inputTable) #开始扫描表
row = cur.Next()# 跳过表头 进入下一行
while row:
if (index == currentRow):#判断行号和索引是否一致
value = row.getValue(inputField)#获取该行 该字段中的值
bContinue = "true" # 把进行一下步的预处理设为真
break
row = cur.Next()
currentRow = currentRow + 1 #开始进入下次循环
del cur
gp.SetParameterAsText(3, str(value))
gp.SetParameterAsText(4, str(bContinue))# 输出
相关文章推荐
- 通过Python脚本读取apk信息
- 字段计算器通过python脚本完成要素节点坐标信息提取到属性字段中
- python工具 - 从文件名读取特定信息到excel表格
- 字段计算器通过python脚本完成要素节点坐标信息提取到属性字段中
- 工具推荐. 在线unix, 在线python/perl脚本测试环境
- python项目:获取微信好友信息(二)csv数据读取与处理
- 在arcgis使用python脚本进行字段计算时是如何解决中文问题的
- selenium+python关于登录的脚本代码,使用了读取excel以及向excel中写入测试结果的方法
- Python读取json文件,并转化为字典进行提取字段(出现索引must be int,not str)解决方案
- Python读取excel指定列生成指定sql脚本
- Python读取图片EXIF信息类库介绍和使用实例
- python ! 点菜脚本 | 正则表达式 | 文件读取
- 查询sql server表的字段、注释、类型等信息
- SQL Server 下读取 表/字段 的说明备注信息
- 获取一个表的,字段,类型,长度,是否主键,是否为空,注释 等信息~
- 从Sql server 2008获取表字段属性信息,注释信息
- mysql 中查询字段信息(字段注释和字段类型)
- SQL Server 2008获取一个表的字段,类型,长度,是否主键,是否为空,注释等信息
- Python读取Word(.docx)正文信息的方法
- python屏幕的交互(读取输出信息)input,raw_input的区别