On Fri, Jan 23, 2009 at 12:38 PM, bob gailer <bgai...@gmail.com> wrote:
> Scott Stueben wrote: > >> Hi all, >> >> I understand that python excels at text processing, and wondered if >> there is a way to use python to accomplish a certain task. <snip> >> I would love to set up a script to parse a file and show results from >> a list of strings. Is this possible with python? >> >> > > Yes - and also possible with almost all other programming languages. > Here is one of several ways to do it in Python: > > for first_name in ('Bob', 'John', 'Joe', 'Jim', 'Fred'): > if first_name in text: > print first_name, 'found' > Another option, if you really like sql, is to import sqlite3 and then parse your text file into a sqlite database. That's probably overkill, of course. But it's a possibility. It really depends on what matters most. Speed? Comfort(with syntax)? Ease of use? That will give you an idea of which tools you should use. HTH, Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor