Re: Noob Parsing question

2015-02-18 Thread kai . peters
> >> > Given > >> > > >> > data = > >> > '{[][]}' > >> > > >> > How can I efficiently get dictionaries for each of the data blocks > >> > framed by <> ? > >> > > >> > Thanks for any help > >> > >> The question here is: What _can't_ happen? For instance, what happens > >> if Fred's name contains

Re: Noob Parsing question

2015-02-17 Thread Chris Angelico
On Wed, Feb 18, 2015 at 3:35 PM, wrote: >> > Given >> > >> > data = >> > '{[][]}' >> > >> > How can I efficiently get dictionaries for each of the data blocks framed >> > by <> ? >> > >> > Thanks for any help >> >> The question here is: What _can't_ happen? For instance, what happens >> if Fred

Re: Noob Parsing question

2015-02-17 Thread kai . peters
> > Given > > > > data = > > '{[][]}' > > > > How can I efficiently get dictionaries for each of the data blocks framed > > by <> ? > > > > Thanks for any help > > The question here is: What _can't_ happen? For instance, what happens > if Fred's name contains a greater-than symbol, or a caret?

Re: Noob Parsing question

2015-02-17 Thread Chris Angelico
On Wed, Feb 18, 2015 at 3:07 PM, wrote: > Given > > data = '{[][]}' > > How can I efficiently get dictionaries for each of the data blocks framed by > <> ? > > Thanks for any help The question here is: What _can't_ happen? For instance, what happens if Fred's name contains a greater-than symbol

Noob Parsing question

2015-02-17 Thread kai . peters
Given data = '{[][]}' How can I efficiently get dictionaries for each of the data blocks framed by <> ? Thanks for any help KP -- https://mail.python.org/mailman/listinfo/python-list

Re: parsley parsing question, how to make a variable grammar

2014-06-16 Thread Eric S. Johansson
On 6/14/2014 8:10 PM, Michael Torrie wrote: On 06/13/2014 03:05 PM, Eric S. Johansson wrote: I appreciate any insight before I go too far off track. --- eric Perhaps this is off-topic, and doesn't answer your question, but is Parsley a natural language parsing tool? If not, and if it is natur

Re: parsley parsing question, how to make a variable grammar

2014-06-14 Thread Michael Torrie
On 06/13/2014 03:05 PM, Eric S. Johansson wrote: > I appreciate any insight before I go too far off track. > --- eric Perhaps this is off-topic, and doesn't answer your question, but is Parsley a natural language parsing tool? If not, and if it is natural language that you're trying to parse, may

parsley parsing question, how to make a variable grammar

2014-06-13 Thread Eric S. Johansson
In my quest for making speech friendly applications, I've developed a very simple domain specific language/notation that works well. I'm using parsley which is a great tool for writing parsers especially simple ones like the one I need. However, I've come across a problem that I don't know how

parsley parsing question

2014-06-01 Thread Eric S. Johansson
how do you parse multi line text with parsley? here is a work in progress and I'm trying to figure out why I need to split the text and process per line vrs all at one go. thanks for any help. --- eric Here's the whole body of code --- import parsley # # grammar to pa

Re: simplified Python parsing question

2012-08-03 Thread BartC
"Eric S. Johansson" wrote in message news:mailman.2752.1343700723.4697.python-l...@python.org... On 7/30/2012 9:54 PM, Steven D'Aprano wrote: It would please me greatly if you would be willing to try an experiment. live my life for a while. Sit in a chair and tell somebody what to type and w

Re: simplified Python parsing question

2012-07-31 Thread Chris Angelico
On Tue, Jul 31, 2012 at 11:54 AM, Steven D'Aprano wrote: > Google Docs is, in my opinion, a nasty piece of rubbish > that doesn't run on any of my browsers. As far as I'm concerned, I'd > rather download a Word doc, because at least I can open that in > OpenOffice or Abiword and read it. Something

Re: OT: accessibility (was "Re: simplified Python parsing question")

2012-07-31 Thread Eric S. Johansson
On 7/30/2012 10:54 PM, Tim Chase wrote: On 07/30/12 21:11, Eric S. Johansson wrote: the ability for multiple people to work on the same document at the same time is really important. Can't do that with Word or Libre office. revision tracking in traditional word processors are unpleasant to work

Re: OT: accessibility (was "Re: simplified Python parsing question")

2012-07-30 Thread Ian Kelly
On Mon, Jul 30, 2012 at 8:54 PM, Tim Chase wrote: > I've tried a similar experiment and am curious on your input device. > Eye-tracking/dwell-clicking? A sip/puff joystick? Of the various > input methods I tried, I found that Dasher[1] was the most > intuitive, had a fairly high input rate and

OT: accessibility (was "Re: simplified Python parsing question")

2012-07-30 Thread Tim Chase
On 07/30/12 21:11, Eric S. Johansson wrote: > the ability for multiple people to work on the same document at > the same time is really important. Can't do that with Word or > Libre office. revision tracking in traditional word processors > are unpleasant to work with especially if your hands a

Re: simplified Python parsing question

2012-07-30 Thread Eric S. Johansson
On 7/30/2012 9:54 PM, Steven D'Aprano wrote: On Mon, 30 Jul 2012 11:40:50 -0400, Eric S. Johansson wrote: If you have been reading the papers, you would understand what I'm doing. That is the second time, at least, that you have made a comment like that. Actually, it's probably more like the

Re: simplified Python parsing question

2012-07-30 Thread Steven D'Aprano
On Mon, 30 Jul 2012 11:40:50 -0400, Eric S. Johansson wrote: > If you have been reading the papers, you would understand what I'm > doing. That is the second time, at least, that you have made a comment like that. Understand that most people are not going to follow links to find out whether or

RE: simplified Python parsing question

2012-07-30 Thread Paul van der Linden
al message- From:Eric S. Johansson Sent:Mon 30-07-2012 12:00 Subject:Re: simplified Python parsing question To:python-list@python.org; On 7/30/2012 5:25 AM, Laszlo Nagy wrote: > > Did you try to use pygments? > > http://pygments.org/docs/api/ > thanks, I'll take a look. >

Re: simplified Python parsing question

2012-07-30 Thread Eric S. Johansson
On 7/30/2012 10:59 AM, Laszlo Nagy wrote: yeah the problem is also little more complicated than simple parsing of Python code. For example, one example (from the white paper) *meat space blowback = Friends and family [well-meaning attempt] *could that be parsed by the tools you mention?

Re: simplified Python parsing question

2012-07-30 Thread Laszlo Nagy
yeah the problem is also little more complicated than simple parsing of Python code. For example, one example (from the white paper) *meat space blowback = Friends and family [well-meaning attempt] *could that be parsed by the tools you mention? It is not valid Python code. Pygments is ab

Re: simplified Python parsing question

2012-07-30 Thread Eric S. Johansson
On 7/30/2012 5:25 AM, Laszlo Nagy wrote: Did you try to use pygments? http://pygments.org/docs/api/ thanks, I'll take a look. I would first tokenize the code, then divide it by statement keywords. Finally, you just need to find expression/assignment statements in the remaining sections.

Re: simplified Python parsing question

2012-07-30 Thread Laszlo Nagy
I appreciate the help because I believe that once this is working, it'll make a significant difference in the ability for disabled programmers to write code again as well as be able to integrate within existing development team and their naming conventions. Did you try to use pygments? htt

Re: simplified Python parsing question

2012-07-30 Thread Dieter Maurer
"Eric S. Johansson" writes: > When you are sitting on or in a name, you look to the left or look to > the right what would you see that would tell you that you have gone > past the end of that name. For example > > a = b + c > > if you are sitting on a, the boundaries are beginning of line and =,

Re: simplified Python parsing question

2012-07-29 Thread Eric S. Johansson
On 7/29/2012 11:33 PM, Steven D'Aprano wrote: On Sun, 29 Jul 2012 19:21:49 -0400, Eric S. Johansson wrote: When you are sitting on or in a name, you look to the left or look to the right what would you see that would tell you that you have gone past the end of that name. For example Have you r

Re: simplified Python parsing question

2012-07-29 Thread Steven D'Aprano
On Sun, 29 Jul 2012 19:21:49 -0400, Eric S. Johansson wrote: > When you are sitting on or in a name, you look to the left or look to > the right what would you see that would tell you that you have gone past > the end of that name. For example Have you read the docs? It gives full details of the

simplified Python parsing question

2012-07-29 Thread Eric S. Johansson
as some folks may remember, I have been working on making Python and its tool base more accessible to disabled programmers. I've finally come up with a really simple technique which should solve 80% of the problem. What I need to figure out is how to find a spot in the code where a symbol exists

Re: Date Parsing Question

2010-09-03 Thread David Bolen
Gavin writes: > python-dateutil seems to work very well if everything is in English, > however, it does not seem to work for other languages and the > documentation does not seem to have any information about locale > support. Probably because I don't think there is much built in. You'll want t

Date Parsing Question

2010-09-03 Thread Gavin
Hi, I'm using the python-dateutil package : http://labix.org/python-dateutil to parse a set of randomly formatted strings into dates. Because the formats are varied, I can't use time.strptime() because I don't know what the format is upfront. python-dateutil seems to work very well if everythin

Re: parsing question

2010-05-31 Thread Tim Chase
On 05/31/2010 08:42 AM, Mag Gam wrote: I have a file with bunch of nfsstat -c (on AIX) which has all the hostnames, for example ... Is there a an easy way to parse this file according to each host? So, r1svr.Connectionless.calls=6553 r1svr.Connectionless.badcalls=0 and so on... I am current

parsing question

2010-05-31 Thread Mag Gam
I have a file with bunch of nfsstat -c (on AIX) which has all the hostnames, for example r1svr== Client rpc: Connection oriented calls badcalls badxids timeouts newcreds badverfs timers 0 0 0 0 0 0 0 nomem cantconn i

Re: File Parsing Question

2007-09-13 Thread Shankarjee Krishnamoorthi
Great. That worked for me. I had some of my routines implemented in Perl earlier. Now that I started using Python I am trying to do all my automation scripts with Python. Thanks a ton Jee On 9/13/07, Peter Otten <[EMAIL PROTECTED]> wrote: > Dennis Lee Bieber wrote: > > > for line in inp: > > > >

Re: File Parsing Question

2007-09-12 Thread Peter Otten
Dennis Lee Bieber wrote: > for line in inp: > > will read one line at a time (I'm fairly sure the iterator doesn't > attempt to buffer multiple lines behind the scenes) You are wrong: >>> open("tmp.txt", "w").writelines("%s\n" % (9*c) for c in "ABCDE") >>> instream = open("tmp.txt") >>> for li

Re: File Parsing Question

2007-09-12 Thread Peter Otten
Am Wed, 12 Sep 2007 17:28:08 -0500 schrieb Shankarjee Krishnamoorthi: > I would prefer to use something with seek. Writing Perl in any language? > I am not able to use seek() > with "for line in inp". Use tell and seek does not seem to do anything > with the code. When I try to do > > for line

Re: File Parsing Question

2007-09-12 Thread Zentrader
> for line in inp.readlines(): If you are now using readlines() instead of readline(), then a) it is only used once to read all data into a container b) you can access each element/line by it's relative number data=open(filename, "r").readlines() for eachline in data : (not readlines()) so try

Re: File Parsing Question

2007-09-12 Thread Shankarjee Krishnamoorthi
I would prefer to use something with seek. I am not able to use seek() with "for line in inp". Use tell and seek does not seem to do anything with the code. When I try to do for line in inp.readlines(): # Top of Loop if not condition in line: do_something else: fo

Re: File Parsing Question

2007-09-12 Thread Zentrader
I'm assuming you know that python has a file.seek(), but you have to know the number of bytes you want to move from the beginning of the file or from the current location. You could save the length of the previous record, and use file seek to backup and then move forward, but it is simpler to save

Re: File Parsing Question

2007-09-12 Thread Zentrader
Save the previous line in a variable if you want the previous line only. for line in inp: # Perform some operations with line if condition something: print prev_line print line break # I need to go back one line and use that line value --> prev_line = line I

File Parsing Question

2007-09-12 Thread Shankarjee Krishnamoorthi
Hi, I am new to Python. I am trying to do the following inp = open(my_file,'r') for line in inp: # Perform some operations with line if condition something: # Start re reading for that position again for line in inp: if some other condition

Re: newbie parsing question

2006-03-25 Thread Paul McGuire
"Kun" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > i have a list of that is: > > [('460 (BODY[HEADER.FIELDS (FROM)] {46}', 'From: Friend > <[EMAIL PROTECTED]>\r\n\r\n'), ')', ('462 (BODY[HEADER.FIELDS (FROM)] {37}', > 'From: Kun <[EMAIL PROTECTED]>\r\n\r\n'), ')'] > > > how do i pa

Re: newbie parsing question

2006-03-24 Thread Fredrik Lundh
"Kun" wrote: > i tried to parse (below) with the regular expression: emails = > re.findall('\S*\s([EMAIL PROTECTED])', senders) > > and got the following error: > > Traceback (most recent call last): >File "/Life/School/Homework/Spring 2006/OPIM > 399/Tutorial/IMAP/scannermailer.py", line 19,

Re: newbie parsing question

2006-03-24 Thread Kun
[EMAIL PROTECTED] wrote: > Use Regular expressions > http://docs.python.org/lib/module-re.html > i tried to parse (below) with the regular expression: emails = re.findall('\S*\s([EMAIL PROTECTED])', senders) and got the following error: Traceback (most recent call last): File "/Life/School/H

Re: newbie parsing question

2006-03-24 Thread raviteja . bhupatiraju
Use Regular expressions http://docs.python.org/lib/module-re.html -- http://mail.python.org/mailman/listinfo/python-list

newbie parsing question

2006-03-24 Thread Kun
i have a list of that is: [('460 (BODY[HEADER.FIELDS (FROM)] {46}', 'From: Friend <[EMAIL PROTECTED]>\r\n\r\n'), ')', ('462 (BODY[HEADER.FIELDS (FROM)] {37}', 'From: Kun <[EMAIL PROTECTED]>\r\n\r\n'), ')'] how do i parse the email addresses out of it into another list or string? -- http://mai