import fme
import fmeobjects
import re
from fmeobjects import FMELogFile
# Template Function interface:
def processFeature(feature):
pass
# Template Class Interface:
class FeatureProcessor(object):
def __init__(self):
pass
def input(self,feature):
name = feature.getAttribute('fme_feature_type')
AttributeNames = feature.getAllAttributeNames()
#FMELogFile().logMessageString(str(AttributeNames))
AtNames = ["ZBLX","PCMC","PZSJ","PZWH","ZYXZ","DKMC","YXDW","XZ","XZC","TDYT","ZYD","XZJSYD","NYD","GD","ST","JSYD","WLYD","YEAR"]
match = ["ZBLX|指标类型","PCMC|批次名|所在批","PZSJ|批准时","PZWH|批准文","ZYXZ|.*征.*","DKMC|具体|项目名","YXDW|单位","XZ|乡镇","XZC|村","TDYT|用途|性质","ZYD|总用地","XZJSYD|新增","NYD|农用地","GD|耕地","ST|水田","JSYD|建设用地","WLYD|未利用","year"]
compnull = re.compile("\s")
for i in AttributeNames:
FMELogFile().logMessageString(i)
for j in match:
reg = re.search(j,i)
if (reg!=None):
ind = match.index(j)
FMELogFile().logMessageString(str(feature.getAttribute(i)))
if (str(feature.getAttribute(i)).replace(" ","") != "" ):
feature.setAttribute(AtNames[ind],feature.getAttribute(i))
FMELogFile().logMessageString("----------------------------")
#feature.removeAttribute(i)
'''
for i in range(0,len(match)):
reg = re.search(match[i][0],name)
if(reg!=None ):
feature.setAttribute('fme_feature_type',match[i][1])
self.pyoutput(feature)
break
'''
self.pyoutput(feature)
def close(self):
pass
06-29
2875
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-27
523
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-13