find first occurrence of ONE string in ONE or MORE mailing lists....PAM!
In [4]:
from bigbang.archive import load as load_archive
In [5]:
#insert ONE OR MORE urls of mailing lists
urls = ["http://lists.ncuc.org/pipermail/ncuc-discuss/",
"http://mm.icann.org/pipermail/wp4/"]
try:
arch_paths =[]
for url in urls:
arch_paths.append('../archives/'+url[:-1].replace('://','_/')+'.csv')
archives = [load_archive(arch_path).data for arch_path in arch_paths]
except:
arch_paths =[]
for url in urls:
arch_paths.append('../archives/'+url[:-1].replace('//','/')+'.csv')
archives = [load_archive(arch_path).data for arch_path in arch_paths]
In [11]:
checkword = 'Freedom of expression'
In [25]:
def get_first_occurrence(word,mailing_list):
for mail in mailing_list.iterrows():
if str.lower(word) in str.lower(mail[1]["Body"]):
return mail
In [26]:
for i in range(0,len(archives)):
first_mail = get_first_occurrence(checkword, archives[i])
print(urls[i])
print(first_mail[1]["Date"])
print(first_mail[1]["From"])
print(first_mail[1]["Body"])
print("****************************************************************")
In [ ]: