1、使用搜索游标查看行中的字段值。
import arcpy # Set the workspace
arcpy.env.workspace = "c:/base/data.gdb" # Create the search cursor
cursor = arcpy.SearchCursor("roads", '"TYPE" <> 4') # Iterate through the rows in the cursor
for row in cursor:
print("Name: {0}, CFCC code: {1}".format(row.NAME, row.CFCC)) del cursor, row 2、使用更新游标更改行中的字段值。
import arcpy

# Set the workspace
arcpy.env.workspace = "c:/base/data.gdb" # Create the update cursor
cursor = arcpy.UpdateCursor("roads") # Update the road buffer distance field based on road type.
# Road type is either 1,2,3,4 Distance is in meters.
for row in cursor:
row.setValue("BUFFER_DIST", row.getValue("TYPE") * 100)
cursor.updateRow(row) # Delete cursor and row objects
del cursor, row
3、使用插入游标在表中新建行。
import datetime
import arcpy # Create insert cursor for table
cursor = arcpy.InsertCursor("c:/base/data.gdb/roads_maint") # Create 25 new rows. Set default values on distance and CFCC code
for i in range(1000, 1025):
row = cursor.newRow()
row.setValue('rowid', i)
row.setValue('distance', 100)
row.setValue('CFCC', 'A10')
row.setValue('LastInsp', datetime.datetime.now())
cursor.insertRow(row) # Delete cursor and row objects
del cursor, row
4、删除记录
with arcpy.da.Editor(arcpy.env.workspace) as edit:
with arcpy.da.UpdateCursor(layerName, ["GB"], 'GB not in (' + layerCodes + ')') as cursor:
for row in cursor:
print("GB Code: {0}".format(row[0]))
cursor.deleteRow()
 


最新文章

  1. 【C语言入门教程】3.1 程序的 3 种基本结构
  2. Java项目相关监控与调优
  3. [译]SQL Server 之 查询计划的简单参数化
  4. 堆(heap)和栈(stack)的区别
  5. rank() over(partition)的使用
  6. 专题一、ArrayList增删操作技术细节详解
  7. python消息队列snakemq使用总结
  8. Linux的rp_filter与策略路由
  9. tensorflow中moving average的用法
  10. 2、使用Angular-CLI初始化Angular项目(踩过的深坑!!!)
  11. HTTP请求行、请求头、请求体详解(转)
  12. Linux下OSG的编译和安装以及遇到的问题
  13. ExtJS5入门
  14. Alan Cox:单向链表中prev指针的妙用
  15. js生成二维码实例
  16. 解决VMware安装Ubuntu的过程中窗口过小无法看到按钮的问题
  17. visual studio 2010 winform程序不能添加对system.web的引用
  18. SpringBoot与Dubbo整合上篇
  19. PHP安全性考虑
  20. POJ 2184 Cow Exhabition

热门文章

  1. 基于python的接口测试框架设计(一)连接数据库
  2. CSocket类的使用
  3. 一个div层在页面上下左右居中以及数据的排序
  4. LeetCode: Longest Valid Parentheses 解题报告
  5. maven jetty指定端口启动
  6. 纯css3实现的3D按钮
  7. 【Unity笔记】屏幕坐标和鼠标坐标
  8. 如何在linux下实现mysql数据库每天自动备份
  9. System.map
  10. yii的一些方法的解析和blog的详细解析