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.
>
-
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
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
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
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
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
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
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,
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