[Tutor] Reading Files and Such
bgailer at gmail.com
Tue Sep 30 00:27:56 CEST 2008
Wayne Watson wrote:
> I have a Python application that requires the program be run in a
> specific folder, Win XP. It analyzes and modifies txt files there, and
> only txt files. The mods require creating a tmp file. The tmp files
> could just as well be an xyz suffix file. That is, it seems as though
> they could be almost any non-conflicting type with hundreds of file
> types in use. There may be other file types in the folder, possibly
> jpg. As such, why would I want to use the tmp files module?
> With a similar program, it requires reading through all txt files,
> among other files types, in the folder. It purely analyzes the data in
> the txt files. Is there some way of doing the reading without the use
> of os.listdir()?
I'm finding it a little hard to grok your question / concern.
One does not use os.listdir() to read files. One opens them then uses
read or readline.
There are many ways to get and filter directory contents.
I guess you would benefit from the glob module.
fileList = glob.glob('*.txt')
Chapel Hill NC
When we take the time to be aware of our feelings and
needs we have more satisfying interatctions with others.
Nonviolent Communication provides tools for this awareness.
As a coach and trainer I can assist you in learning this process.
What is YOUR biggest relationship challenge?
More information about the Tutor