I have 2 lists. 1 is a list of elements service names, and the second is a list of materials.
I would like to match the elements service name that contains the material name(shorter string). then pass the element and the material name so I can assign the correct material to the element. I have been using string.contains and list.filterbyboolmask. However I cannot get a list of materials matched to elements.
@pipefitter72 Not sure how accurate this would be. But try look into fuzzy string matching.
There is a package called FuzzyDyno to get started with. But I don’t prefer that since it always freezes on me.
Alternatively, you can download the fuzzywuzzy python package and do something like this:
That looks like what I need. However after installing fuzzywuzzy from github. I must not be doing something right. I keep getting the following error.
@pipefitter72 Try this:
-
Download the package by clicking on this link: https://github.com/seatgeek/fuzzywuzzy/archive/refs/heads/master.zip
-
Open the downloaded zip file and extract the fuzzywuzzy folder on your desktop
-
Change your code as below and replace YOURUSERNAME with your windows username
import sys
sys.path.append(r'C:\Users\YOURUSERNAME\Desktop')
from fuzzywuzzy import process
OUT=[]
for x in IN[0]:
OUT.append(process.extractOne(x,IN[1])[0])
LOL I was coming to post that I figured what I was doing wrong. But I see you beat me to it.
I have it working now, but not giving the result I need exactly. I will see what I can do with it. Thanks.
I keep trying that setup, but I have begun to think the service names are too long to be handled. some of them are 30+ characters long
You do have a list transpose after the contains node. Have you removed that?
I have tried with and without