Hi all,
I had a script working on 2.7 (our previous default) and have now switched to 3.6 to keep up to date.
I am getting a syntax error on line 18, but I can't see why, it is probably something obvious I am missing...
Also any feedback on the script would be cool, I am still new to python so would be appreciated!
Thanks in advance
#import libraries that we will potentially need
import difflib
import fme
import fmeobjects
#create the class for execution, as per the FME spec:
#https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/pythoncaller.htm
class addressMatch(object):
def __init__(self):
self.dataD = []
self.pread = ''
self.outputIndex = 0
self.tmp = 0
self.matchRate = 0
def input(self,feature):
if self.pread <> feature.getAttribute('CURRENT_ADDRESS') and self.pread <> '':
#Error here
for index, item in enumerate(self.dataD):
self.tmp = difflib.SequenceMatcher(None,item.getAttribute('CURRENT_ADDRESS'),item.getAttribute('full_address')).quick_ratio()
if self.tmp > self.matchRate:
self.matchRate = self.tmp
self.outputIndex = index
if self.tmp >= 0.95:
break
self.dataD[self.outputIndex].setAttribute("matchRating",self.matchRate)
self.pyoutput(self.dataD[self.outputIndex])
self.dataD = []
self.dataD.append(feature)
self.pread = feature.getAttribute('CURRENT_ADDRESS')
def close(self):
self.outputIndex = 0
self.tmp = 0
self.matchRate = 0
for idx, item in enumerate(self.dataD):
self.tmp = difflib.SequenceMatcher(None,item.getAttribute('CURRENT_ADDRESS'),item.getAttribute('full_address')).quick_ratio()
if self.tmp > self.matchRate:
self.matchRate = self.tmp
self.outputIndex = idx
if self.tmp >= 0.95:
break
self.dataD[self.outputIndex].setAttribute("matchRating",self.matchRate)
self.pyoutput(self.dataD[self.outputIndex])
Best answer by david_r
View original