"Scott Stueben" <sidewalk...@gmail.com> wrote

As I think more about how to best do this, I wonder if/how python
script would import File A with search values, File B to be searched,
and write each full line containing any of those results to File C.
The code could be set to look for the same input file (A, with the
search values), and the same filename to write to (File C), thus
leaving only the prompt for the file to be searched (File B).

Thats pretty straightforward to do.

In pseudo code:

fileB = open(raw_input("Filename to search: "))
searches = [s for s in open("FileA.txt")]
results = Set()
for line in fileB:
    for s in searches:
         if s in line: results.add(line+'\n')

open("FileC.txt").writelines(results)


Not the most efficient solution but that can be tweaked
using some of the other suggestions from earlier.

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to