Home > Software engineering >  IF statements not calling my data after continue statement
IF statements not calling my data after continue statement

Time:12-20

When I run the below code, I am getting a bunch of rows back saying "no results"

I'd like to see if the address is similar by using the string_len_test function and then if it's not similar for each address to undergo some sort of fuzzy matches. And if the results of each comparison are a certain value % value then I want to perform some logic to them (right now I just have print statements). I know for a fact that my data has high matching scores but they seem to be getting skipped in this if/else statement.

def string_len_test(l_value, v_value):
  if abs(len(l_value) - len(v_value)) >2:
    #print('not matched')
    return False
  elif abs(len(l_value) - len(v_value)) == 0:
    #print('potential match', l_value, v_value)
    return True
  else:
    return False
    

for link in Address1.itertuples():
  if link._5 == 'X':
      match_table = Adddress_main_X
  else:
      match_table = Adddress_main_Y

  for v in match_table.itertuples():
    
    if not string_len_test(link.Address_1, v.Address_2):
       continue 

    lev_score = lev(link.Address_1, v.Address2)
    fuzz_score = fuzz.token_sort_ratio(link.Address_1, v.Address2)
      #print(lev_score)
      #print(fuzz_score)
    if lev_score >=98 | fuzz_score >90:
      print('match', link.Address_1, v.Address2)
    if lev_score >= 80:
      print('close', link.Address_1, v.Address2)
    else:
      print('no results')

CodePudding user response:

added an else pass statement and got rid of the continue statement. Thank you all for the help!

  • Related