Re: Searching through more than one file.

2014-12-29 Thread Cem Karan
On Dec 29, 2014, at 2:47 AM, Rick Johnson wrote: > On Sunday, December 28, 2014 11:29:48 AM UTC-6, Seymore4Head wrote: >> I need to search through a directory of text files for a string. >> Here is a short program I made in the past to search through a single >> text file for a line of text. >

Re: Searching through more than one file.

2014-12-29 Thread Albert-Jan Roskam
- On Sun, Dec 28, 2014 8:12 PM CET Dave Angel wrote: >On 12/28/2014 12:27 PM, Seymore4Head wrote: >> I need to search through a directory of text files for a string. >> Here is a short program I made in the past to search through a single >> text file for a line of tex

Re: Searching through more than one file.

2014-12-28 Thread Rick Johnson
On Sunday, December 28, 2014 11:29:48 AM UTC-6, Seymore4Head wrote: > I need to search through a directory of text files for a string. > Here is a short program I made in the past to search through a single > text file for a line of text. Step1: Search through a single file. # Just a few more bru

Re: Searching through more than one file.

2014-12-28 Thread Terry Reedy
On 12/28/2014 12:27 PM, Seymore4Head wrote: I need to search through a directory of text files for a string. Here is a short program I made in the past to search through a single text file for a line of text. How can I modify the code to search through a directory of files that have different fi

Re: Searching through more than one file.

2014-12-28 Thread Paul Rubin
Dave Angel writes: > res = set() > fnames = glob('*.txt') > for line in fileinput.input(fnames): > res.update(line.rstrip().split()) > print sorted(res) Untested: print sorted(set(line.rstrip().split() for line in fileinput(fnames))) -- https://mail.python.org/mailman/listinfo/python-list

Re: Searching through more than one file.

2014-12-28 Thread Dave Angel
On 12/28/2014 02:12 PM, Dave Angel wrote: On 12/28/2014 12:27 PM, Seymore4Head wrote: I need to search through a directory of text files for a string. Here is a short program I made in the past to search through a single text file for a line of text. How can I modify the code to search through

Re: Searching through more than one file.

2014-12-28 Thread Dave Angel
On 12/28/2014 12:27 PM, Seymore4Head wrote: I need to search through a directory of text files for a string. Here is a short program I made in the past to search through a single text file for a line of text. How can I modify the code to search through a directory of files that have different fi

Re: Searching through more than one file.

2014-12-28 Thread Paul Rubin
Seymore4Head writes: > How can I modify the code to search through a directory of files that > have different filenames, but the same extension? Use the os.listdir function to read the directory. It gives you a list of filenames that you can filter for the extension you want. Per Mark Lawrence,

Re: Searching through more than one file.

2014-12-28 Thread Mark Lawrence
On 28/12/2014 17:27, Seymore4Head wrote: I need to search through a directory of text files for a string. Here is a short program I made in the past to search through a single text file for a line of text. How can I modify the code to search through a directory of files that have different filen

Searching through more than one file.

2014-12-28 Thread Seymore4Head
I need to search through a directory of text files for a string. Here is a short program I made in the past to search through a single text file for a line of text. How can I modify the code to search through a directory of files that have different filenames, but the same extension? fname = raw_