在ArcMap中,我想在字段中查找并替换地址的一部分。例如,我的地理数据库表中有字段,如" None None,Queenstown"。我想替换"无无,"与空白文本。我正在考虑使用UpdateCursor这样做。
到目前为止,我可以获得包含"无无的功能,":
with arcpy.da.UpdateCursor(fcOrganisation, fields) as cursor:
for row in cursor:
if "None None, , " in row[0]:
print "C = %s" % (row[0])
然后,这给我一个包含"无无,,":
的行的列表C = None None, , Stutterheim
C = None None, , Bhisho
C = None None, , Queenstown
C = None None, , East London
C = None None, , East London
C = None None, , Port Elizabeth
C = None None, , Alice
C = None None, , Port Elizabeth
我现在想要只更换"无无,"所以我只得到镇名:
Stutterheim
Bhisho
Queenstown
East London
East London
Port Elizabeth
Alice
Port Elizabeth
我可以在ArcMap表格中的字段上执行此操作。有没有办法使用python / arcpy并使用UpdateCursor?
感谢您的帮助。
答案 0 :(得分:0)
像这样:
with arcpy.da.UpdateCursor(fcOrganisation, fields) as cursor:
for row in cursor:
srchStr = "None None, , "
if srchStr in row[0]:
print "C = %s" % (row[0])
cursor.updateRow(row[0][len(srchStr):])