AnsweredAssumed Answered

Python Lookup Table?

Question asked by johnmdye on Dec 2, 2013
Latest reply on Dec 5, 2013 by twhit5148
I'm trying to make a lookup table of sorts in my code.

I have a SearchBox in which a user can enter the name of any retailer to search for the retailer in our retailer database. If found, a layerfile will be created and populated in the dataframe for the given retailer.

What the user enters into that searchbox is instantiated under the variable 'SearchTerm'.

Since a user's 'SearchTerm' is going to be inherenly subjective, I'm trying to figure out how I can account for common variances in a 'SearchTerm' which should equate to the same retailer.

For Example:
If the user is searching for the Retailer 'TJ Maxx', they might enter into the SearchBox any one one of the following:

'TJ Maxx', 'TJ Max' or 'TJX'

All three of those search terms should resolve to 'TJMaxx', which is how it is identified in the database. I thought about perhaps using a python dictionary where the name of the dataset in the Database would be the key and the possible search terms could be the values, but when I played with it I couldn't find a way to associate multiple values with a single key in a super simple way.

Basically, I just need to figure out an efficient way to resolve multiple 'tags' to a single, unique return, if that makes any sense.

Outcomes