arcgis出界址点成果表_界址点成果表打印

这段代码展示了如何使用Python的openpyxl和ArcGIS库来处理Excel文件中的数据。它实现了替换工作表中特定模式的文本,并计算几何特征的面积和长度。此外,它还涉及了将数据写入新的Excel文件并进行宗地和界址点的处理。
摘要由CSDN通过智能技术生成

#coding: UTF-8

importarcpyimportosimporttypesimportstringimportshutilimportsysimportreimportopenpyxl#ws是一个xls的工作表#mode是替换模型,1完全替换,2模糊替换,3 追加替换

defreplacexls(ws,mode, text, replaceText):

rows=ws.max_row

cols=ws.max_column

changeCells=0if (mode <0):return -1

elif (mode>3):return -1

for row in range(1, rows + 1):for col in range(1, cols + 1):try:

content= ws.cell(row=row, column=col).valueif (content !=None):#mode1: fullmatch replacement

if (mode == 1):if (content ==text):

ws.cell(row=row, column=col).value =replaceText

changeCells+= 1

#mode2: partial replacement

elif (mode == 2):if (type(content) ==str):

ws.cell(row=row, column=col).value = content.replace(text, replaceText, 1)

changeCells+= 1

#mode3: partialmatch and filling

elif (mode == 3):if (type(content) ==str):

ws.cell(row=row, column=col).value = content.replace(text, text + replaceText, 1)

changeCells+= 1

exceptException as e:print(traceback.format_exc())returnchangeCellsdefchangeData(file, mode, text, replaceText):#load the file(*.xlsx)

wb =openpyxl.load_workbook(file)#! deal with one sheet

ws=wb.worksheets[0]

replacexls(ws, mode, text, replaceText)definitProgress(hint,num):

arcpy.SetProgressor(

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值