I have a dictionary which i fetch from MySql DB, the ID is the key and the value is a string (relative Windows path of files to be exact). I have another list which has windows path as elements. Now, I need to match the list elements with the dictionary values and if exact match is found, i need to retrieve the key for that element, if not present, i'll update in the DB
My current code:
for line in f1:
line = line.strip()
try:
index = next(k for (k,v) in self.db_file_list.iteritems() if line in v)
file_list_csv.append(index)
The problem here is: Suppose value in my dictionary is "abc def", "a/b/c" then if i search values "abc" or "a/b" it would still match and give me key value which is not what i want.
Please help me out, i am a newbie to Python. Many thanks in advance!
~Saurav