Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file contents searching

Status
Not open for further replies.

Marktric

Technical User
May 7, 2003
1
US
Out of necessity, I am learning Python. The first project I am attempting seemed to be relatively easy when I thought of it, but has become a challenge to really get into.

What I need to do is open an unknown number of files of a certain type in a user specified directory, search for a regex string in the first file, then compare that string to each additional file and report a found/not found status in an output file.

I have been searching around, and found some of this info...that's what led me to this forum. If someone could give me a general idea of what concepts to look out for, or a tutorial suited to this application, I would greatly appreciate it.

Thanks,
Mark.
 
Take a look at those modules:

glob, listdir or os.path.walk+fnmatch to get the list of files.
open to read files.
re for regular expressions.

You will achieve what you want with these modules.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top