On Sun, 13 Oct 2013 22:34:43 -0700, Starriol wrote:

> I'm trying to search for several strings, which I have in a .txt file
> line by line, on another file.
> So the idea is, take input.txt and search for each line in that file in
> another file, let's call it rules.txt.
> 
> So far, I've been able to do this, to search for individual strings:
> 
> [code]import re
> 
> shakes = open("output.csv", "r")
> 
> for line in shakes:
>     if re.match("STRING", line):
>         print line,[/code]
> 
> How can I change this to input the strings to be searched from another
> file?
> 
> So far I haven't been able to.

read all the search strings into a list

while there's data in shakes
     read a line from shakes
     for each string in search string list
         search the line from shakes for the search string

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to