[Tutor] Parsing Question

Michael Morrissey gdoghomes at gmail.com
Sun May 10 01:23:02 CEST 2009


Forgive me if I'm asking something stupid, but I'm not sure how to do this
(there are so many options in Python, I'm overwhelmed and confused). I have
a text file that looks like this:
1 the 126 name
2 of 127 very
3 to 128 through
4 and 129 just
5 a 130 form
6 in 131 much
7 is 132 great
etc...

Each has 2 numbers and 2 words on it. Each number is related to the word
that comes after it. So "1" and "the" are connected (kinda like a
dictionary), and "126" and "name" are related.

Using the above text file as an input, I'm trying to make an output that
lists all the words, one word per line, but none of the numbers. I was
hoping to get the words listed in order of their related numbers. So, the
output needs to look like:

the
of
to
.... (skip to the 127th line)
very
through
just

I can open and loop over the text, I'm just not sure what commands I should
use to parse each line. Can anyone give me suggestions or examples?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090510/cd021285/attachment.htm>


More information about the Tutor mailing list