mail
Grant Edwards
invalid at invalid
Wed Jul 15 15:05:30 EDT 2009
On 2009-07-15, amrita at iisermohali.ac.in <amrita at iisermohali.ac.in> wrote:
> Sorry that I am disturbing you all again and again but this is the way I
> am trying to solve my problem:---
We could probably be a lot more helpful if you would keep these
postings all in a single thread so that people who didn't read
the first postings knew what you were talking about in
subsequent postings.
>>>> import re
>>>> exp = re.compile("CA")
> [...]
>
> file is something lookin like:-----
>
> 47 8 ALA H H 7.85 0.02 1
[...]
IMO you're making a mistake using the "re" module for this
task. I think you'd be a lot better off if you just used the
string type's split method to split each line up into fields
and processed the individual fields:
for line in inputfile:
field = line.split()
if field[2] == "CA":
<<do whatever with whichever fields you care about>>
elif field[2] == "soemthing-else"
<<do something else with some other fields>>
<<print results of doing whatever and something else above>>
--
Grant Edwards grante Yow! If I felt any more
at SOPHISTICATED I would DIE
visi.com of EMBARRASSMENT!
More information about the Python-list
mailing list