rss - Python: efficient comparison of strings in lists -
i monitoring rss feed using feedparser. feed has 100 items , extracting time stamp unique identifier in form of list of strings. single item looks of list like: 2017-07-25t20:41:59-04:00
next, doing python magic other data feed parsed lists (same index, different lists though) extract information want. part works well, love it.
now problem: after time delay
import time time.sleep(60)
i'd monitor feed again , see efficiently if time stamp observed before. if so, i'd pass on executing code , wait more until uniqe time stamp shows up.
i failed implement far. thought making second list , comparing two. each list has 100 items. new items appear on top of feed , move down on time. should fine if run first match. should make code more efficient comparing everything.
i'd happy iif point me towards solution. stuck whatever have tried, failed.
edit:
def compare(feed_id_l, feed_id_check_l): #compares items in lists , returns index in range(0, len(feed_id_l)): j in range(0, len(feed_id_check_l)): if feed_id_l[i] == feed_id_check_l[j]: print('match id ' + feed_id_l[i]) return i, j else: return -1
works , returns 0, 0 if first feed item unchanged.
i have figure out other cases, let's 0, 6.
cheers!
Comments
Post a Comment