Hi
I have two python lists. list1 is a \n delimited web proxy log file. list2 is a list of domain names. I want to cycle through the list of domain names and for every log file entry check if the domain name exists anywhere in the log entry. If it exists then print out the log entry in full to stdout.
list1 = [20100122 http google.com 200, 20100124 http hushmail.com 200, 20100123 http microsoft.com 404 ]
list2 = [google.com, yahoo.com, msn.com, hotmail.com, gmail.com]
The expected result of the python script would be:
$./parse-logfile.py
Line 1: 20100122 http google.com 200
Line 3: 20100123 http microsoft.com 404
$
Psuedo code would look something like:
read in list1, read in list2
for each entry in list2
for each entry in list1
if entry in list1 exists anywhere in list2 then
print 'Line', linenum
print Log Entry
I've played with strings, lists and sets but can't see to find exactly what I need.
Thanks.