Re: [Tutor] how to get blank value

2009-07-28 Thread Paul McGuire
> -Original Message- > From: amr...@iisermohali.ac.in [mailto:amr...@iisermohali.ac.in] > Sent: Wednesday, July 29, 2009 12:13 AM > To: Paul McGuire > Cc: tutor@python.org > Subject: Re: [Tutor] how to get blank value > > Thanks for help Sir but with these comm

Re: [Tutor] how to get blank value

2009-07-28 Thread amrita
Thanks for help Sir but with these commands it is showing error:- ph08...@sys53:~> python trip.py Traceback (most recent call last): File "trip.py", line 6, in from pyparsing import * ImportError: No module named pyparsing > Ok, I've seen various passes at this problem using regex, split(

Re: [Tutor] how to get blank value

2009-07-28 Thread Paul McGuire
Ok, I've seen various passes at this problem using regex, split('='), etc., but the solutions seem fairly fragile, and the OP doesn't seem happy with any of them. Here is how this problem looks if you were going to try breaking it up with pyparsing: - Each line starts with an integer, and the stri

Re: [Tutor] how to get blank value

2009-07-28 Thread Dave Angel
amr...@iisermohali.ac.in wrote: It is not giving any value, without any error ph08...@sys53:~> python trial.py ph08...@sys53:~> it is coming out from shell. Thanks for help. Amrita amr...@iisermohali.ac.in wrote: Sorry to say, but till now I have not got the solution of my problem, I

Re: [Tutor] how to get blank value

2009-07-28 Thread शंतनू
You may like to have a look @ pyparsing module. URL: http://pyparsing.wikispaces.com/ HTH. regards, shantanoo On 29-Jul-09, at 1:03 AM, amr...@iisermohali.ac.in wrote: with these data it is giving output but when I tried if __name__ == '__main__': data = open('chem.txt').readlines() for line

Re: [Tutor] how to get blank value

2009-07-28 Thread amrita
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

Re: [Tutor] how to get blank value

2009-07-28 Thread Alan Gauld
wrote Sorry to say, but till now I have not got the solution of my problem, I tried with this command:- import re if __name__ == '__main__': data = open('chem.txt').readlines() for line in data: RE = re.compile('C = (.)',re.M) The regex still does not match the end of line.

Re: [Tutor] how to get blank value

2009-07-28 Thread bob gailer
amr...@iisermohali.ac.in wrote: It is not giving any value, without any error ph08...@sys53:~> python trial.py ph08...@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

Re: [Tutor] how to get blank value

2009-07-28 Thread amrita
It is not giving any value, without any error ph08...@sys53:~> python trial.py ph08...@sys53:~> it is coming out from shell. Thanks for help. Amrita > amr...@iisermohali.ac.in wrote: >> Sorry to say, but till now I have not got the solution of my problem, I >> tried with this command:- >> >> imp

Re: [Tutor] how to get blank value

2009-07-28 Thread bob gailer
amr...@iisermohali.ac.in wrote: Sorry to say, but till now I have not got the solution of my problem, I tried with this command:- import re # assuming H = , N = , CA = , HA = and C = always present in that order if __name__ == '__main__': data = open('chem.txt').readlines() for line in d

Re: [Tutor] how to get blank value

2009-07-28 Thread amrita
Sorry to say, but till now I have not got the solution of my problem, I tried with this command:- import re if __name__ == '__main__': data = open('chem.txt').readlines() for line in data: RE = re.compile('C = (.)',re.M) matches = RE.findall(line) for m in mat

Re: [Tutor] how to get blank value

2009-07-25 Thread Alan Gauld
wrote With these commands:- import re f = open('chem.txt') for line in f: if re.search('C = ',line): print line I am getting those lines for which C value is there but how to get those one for which it doesn't have any value, i did google search but still i am not getting. Don;

Re: [Tutor] how to get blank value

2009-07-24 Thread Albert-Jan Roskam
Mark Summerfield recently wrote a book called Programming in Python 3 (http://www.qtrac.eu/py3book.html) The chapter on regexes happens to be freely downloadable as a sample chapter: http://ptgmedia.pearsoncmg.com/images/9780137129294/samplepages/0137129297_Sample.pdf I found that chapter (in f

Re: [Tutor] how to get blank value

2009-07-24 Thread Luke Paireepinart
You will probably continue to get unsatisfactory responses if you continue to ask unsatisfactory questions.Python won't automatically parse this document in exactly the way you want it to. You're on the right track but you need to do as Alan said and actually read the regex articles to understand

Re: [Tutor] how to get blank value

2009-07-24 Thread amrita
> What is the python command for searching blank value of a parameter? > 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

Re: [Tutor] how to get blank value

2009-07-24 Thread ALAN GAULD
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 lin

Re: [Tutor] how to get blank value

2009-07-24 Thread Alan Gauld
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