惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

博客园 - Brune

批量Clip 初步完成ArcGIS Silverlight的数据源扩展 GPServer发布的一个怪问题 高焕堂Android應用框架原理與程式設計代码补遗(一) - Brune - 博客园 GMapViewer初具雏形 FileGeodatabase的一个发现 搞定3G上网 ArcGIS SDK for .Net咋就不能自动释放对象呢 Fluorine中的ORA-12640错误 在Sql Server 2008上安装SDE 9.3 终于可以通过Flex上传文件到数据库了 SqlServer 空间数据的初体验 Flex SDK 4.0I配置 Windows Server 2008中配置FluorineFx 庶民GIS的时代渐渐到来了 题外话 Flex下的ArcIMS开发──环境配置(上) ArcGIS Server Flex ADF 即将到来 新迭代的开始
要素类属性内容全角换半角
Brune · 2013-06-01 · via 博客园 - Brune

近期天地图项目处理数据时由于原始数据质量较差,属性字段中多有全角字符,带来后期处理与开发不便,因此做了个属性全角换半角的脚本如下

经验:Unicode处理

# -*- coding: utf-8 -*-

__author__ = 'tanshuai'

import arcpy

from arcpy import env

fullCorner = ['0' , '1' , '2' , '3' , '4' ,

'5' , '6' , '7' , '8' , '9' ,

'A' , 'B' , 'C' , 'D' , 'E' ,

'F' , 'G' , 'H' , 'I' , 'J' ,

'K' , 'L' , 'M' , 'N' , 'O' ,

'P' , 'Q' , 'R' , 'S' , 'T' ,

'U' , 'V' , 'W' , 'X' , 'Y' ,

'Z' , 'a' , 'b' , 'c' , 'd' ,

'e' , 'f' , 'g' , 'h' , 'i' ,

'j' , 'k' , 'l' , 'm' , 'n' ,

'o' , 'p' , 'q' , 'r' , 's' ,

't' , 'u' , 'v' , 'w' , 'x' ,

'y' , 'z' , '-' , ' ' , ':' ,

'.' , ',' , '/' , '%' , '#' ,

'!' , '@' , '&' , '(' , ')' ,

'<' , '>' , '"' , ''' , '?' ,

'[' , ']' , '{' , '}' , '\' ,

'|' , '+' , '=' , '_' , '^' ,

'¥' , ' ̄' , '`']

halfCorner = ['0', '1', '2', '3', '4',

'5', '6', '7', '8', '9',

'A', 'B', 'C', 'D', 'E',

'F', 'G', 'H', 'I', 'J',

'K', 'L', 'M', 'N', 'O',

'P', 'Q', 'R', 'S', 'T',

'U', 'V', 'W', 'X', 'Y',

'Z', 'a', 'b', 'c', 'd',

'e', 'f', 'g', 'h', 'i',

'j', 'k', 'l', 'm', 'n',

'o', 'p', 'q', 'r', 's',

't', 'u', 'v', 'w', 'x',

'y', 'z', '-', ' ', ':',

'.', ',', '/', '%', '#',

'!', '@', '&', '(', ')',

'<', '>', '"', '\'','?',

'[', ']', '{', '}', '\\',

'|', '+', '=', '_', '^',

'¥','~', '`']

def replaceCharacter(fldValueText):

    for full in fullCorner:

        if fldValueText.find(full) > -1:

            index = fullCorner.index(full)

            half = halfCorner[index];

            fldValueText = fldValueText.replace(full, half)

    print fldValueText

    return fldValueText

env.workspace = "E:\\test2"

length = len(fullCorner)

cursor = arcpy.UpdateCursor("test3.shp")

try:

    for row in cursor:

        fieldList = arcpy.ListFields("test3.shp")

        for field in fieldList:

            if field.type == "String":

                value = row.getValue(field.name)

                valueTxt = value.encode('utf-8')

                if len(valueTxt) > 0:

                    print valueTxt

                    resultValue = replaceCharacter(valueTxt)

                    row.setValue(field.name, resultValue)

                    cursor.updateRow(row)

                    print resultValue

                else:

                    continue

except Exception,e:

    print("错误"+e)

finally:

    del row,cursor

print("complete!")