I'm iterating through excel files and logging rows that contain a string, like so:
def find_string_row(toFind, dframe):
index = 0
while toFind not in dframe.iloc[index].values:
print(dframe.iloc[index].values)
index = index+1
return index
I have some new files that are quite messy, and contain strings with whitespace inside and outside the text. So while the above works for exact matches, it fails for loose matches. How can I rewrite this to find strings in this manner:
toFind.replace(" ", "").lower()
so if I input a string like "Address 1 23 " and the excel contains " add ress 12 3" they will match?
" "with""and addinglower()onlyaddress123will match.