[Tutor] how to get blank value

amrita at iisermohali.ac.in amrita at iisermohali.ac.in
Tue Jul 28 21:33:53 CEST 2009


with these data it is giving output but when I tried

if __name__ == '__main__':
  data = open('chem.txt').readlines()
  for line in data:
      line2 = line.split('=')
      if not line2[5]: # C value missing
        if len(line2[2]) <= 5 and len(line2[3]) <= 5:  # N and CA values
missing
          print "all missing", line
        else:
          print "C missing", line

by putting data in .txt file then it is not giving output. Actually I have
few large data file what I want that I will put those lines in one file
for which only C value is missing and in another one I will put those line
for which N, CA and C all values are missing.

Thanks for help.
Amrita

> amrita at iisermohali.ac.in wrote:
>> It is not giving any value, without any error
>>
>> ph08001 at sys53:~> python trial.py
>> ph08001 at sys53:~>
>> it is coming out from shell.
>>
> Try this. I embedded the test data to simplify testing:
>
> data = """48 ALA H = 8.33 N = 120.77 CA = 55.18 HA = 4.12 C = 181.50
> 104 ALA H = 7.70 N = 121.21 CA = 54.32 HA = 4.21 C =
> 85 ALA H = 8.60 N =  CA =  HA = 4.65 C =""".split('\n')
> for line in data:
>     line2 = line.split('=')
>     if not line2[5]: # C value missing
>       if len(line2[2]) <= 5 and len(line2[3]) <= 5: # N and CA values
> missing
>         print "all missing", line
>       else:
>         print "C missing", line
>
> --
> Bob Gailer
> Chapel Hill NC
> 919-636-4239
>


Amrita Kumari
Research Fellow
IISER Mohali
Chandigarh
INDIA



More information about the Tutor mailing list