[Tutor] how to get blank value
alan.gauld at btinternet.com
Fri Jul 24 11:08:54 CEST 2009
Please use Reply All to send it to the list as well.
> I am trying it in this way also:---
> import re
> expr = re.compile("C")
This will find all lines with the letter C in them.
Which from your data is all of them. Look at the regex documentation
to see how to represent the end of a line (or, slightly more complex, a
> f = open('chem.txt')
> for line in f:
> if 'C = '
This is invalid Python, the second level of indentation should produce an error!
Also you are not doing anything with the result of your search, you just throw
You need something like
for line in open('chem.txt'):
> > wrote
> >> 48 ALA H = 8.33 N = 120.77 CA = 55.18 HA = 4.12 C = 181.50
> >> 104 ALA H = 7.70 N = CA = HA = 4.21 C =
> >> Now i want to make two another file in which i want to put those lines
> >> for
> >> which C is missing and another one for which N,CA and C all are missing,
> >> I tried in this way:
> >> import re
> >> expr = re.compile("C = None")
> > This will search for the literal string 'C = None' which does not exist in
> > your sdata.
> > You need to search for 'C = 'at the end of the line (assuming it is always
> > there.
> > Otherwise you need to search for 'C = ' followed by a non number.)
> > HTH,
> > --
> > Alan Gauld
> > Author of the Learn to Program web site
> > http://www.alan-g.me.uk/
> > _______________________________________________
> > Tutor maillist - Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> Amrita Kumari
> Research Fellow
> IISER Mohali
More information about the Tutor