[issue401634] SAX: Fix parse and parseString, support parsing of open file

2022-04-10 Thread admin
Change by admin : -- github: None -> 33187 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue401634] SAX: Fix parse and parseString, support parsing of open file

2022-04-10 Thread admin
Change by admin : ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

Re: parsing encrypted netrc file

2020-06-23 Thread Barry Scott
> On 22 Jun 2020, at 23:38, Seb wrote: > > Hello, > > What's the pythonic way to do this without polluting the user's > directory with the decrypted file? I wrongly thought this should do it: > > import os.path as osp > import gnupg > import netrc > import tempfile > > gpg = gnupg.GPG() >

Re: parsing encrypted netrc file

2020-06-23 Thread Seb
On Tue, 23 Jun 2020 02:08:19 +0100, MRAB wrote: [...] > Here's a page I found about ".netrc": > https://ec.haxx.se/usingcurl/usingcurl-netrc > and here's a page I found about ".authinfo.gpg": > https://www.emacswiki.org/emacs/GnusAuthinfo > Can you see the subtle difference? Awww nuts, I

Re: parsing encrypted netrc file

2020-06-22 Thread MRAB
On 2020-06-23 01:47, Seb wrote: On Tue, 23 Jun 2020 00:40:28 +0100, MRAB wrote: On 2020-06-22 23:38, Seb wrote: Hello, What's the pythonic way to do this without polluting the user's directory with the decrypted file? I wrongly thought this should do it: import os.path as osp import

Re: parsing encrypted netrc file

2020-06-22 Thread Seb
On Tue, 23 Jun 2020 00:40:28 +0100, MRAB wrote: > On 2020-06-22 23:38, Seb wrote: >> Hello, >> What's the pythonic way to do this without polluting the user's >> directory with the decrypted file? I wrongly thought this should do >> it: >> import os.path as osp import gnupg import netrc

Re: parsing encrypted netrc file

2020-06-22 Thread MRAB
On 2020-06-22 23:38, Seb wrote: Hello, What's the pythonic way to do this without polluting the user's directory with the decrypted file? I wrongly thought this should do it: import os.path as osp import gnupg import netrc import tempfile gpg = gnupg.GPG() with

parsing encrypted netrc file

2020-06-22 Thread Seb
Hello, What's the pythonic way to do this without polluting the user's directory with the decrypted file? I wrongly thought this should do it: import os.path as osp import gnupg import netrc import tempfile gpg = gnupg.GPG() with open(osp.expanduser("~/.authinfo.gpg"), "rb") as f: with

Re: Help parsing a text file

2011-09-01 Thread JT
On Monday, August 29, 2011 1:21:48 PM UTC-5, William Gill wrote: I have a text file with XML like records that I need to parse. By XML like I mean records have proper opening and closing tags. but fields don't have closing tags (they rely on line ends). Not all fields appear in all

Re: Help parsing a text file

2011-09-01 Thread William Gill
On 9/1/2011 1:58 PM, JT wrote: On Monday, August 29, 2011 1:21:48 PM UTC-5, William Gill wrote: I have a text file with XML like records that I need to parse. By XML like I mean records have proper opening and closing tags. but fields don't have closing tags (they rely on line ends). Not all

Re: Help parsing a text file

2011-08-30 Thread Waldek M.
On Mon, 29 Aug 2011 23:05:23 +0200, Thomas Jollans wrote: A name that is often thrown around on this list for this kind of question is pyparsing. Now, I don't know anything about it myself, but it may be worth looking into. Definitely. I did use it and even though it's not perfect - it's very

Re: Help parsing a text file

2011-08-30 Thread Tim Roberts
William Gill noreply@domain.invalid wrote: My initial passes into Python have been very unfocused (a scatter gun of too many possible directions, yielding very messy results), so I'm asking for some suggestions, or algorithms (possibly even examples)that may help me focus. I'm not asking

Help parsing a text file

2011-08-29 Thread William Gill
I haven't done much with Python for a couple years, bouncing around between other languages and scripts as needs suggest, so I have some minor difficulty keeping Python functionality Python functionality in my head, but I can overcome that as the cobwebs clear. Though I do seem to keep

Re: Help parsing a text file

2011-08-29 Thread Philip Semanchuk
On Aug 29, 2011, at 2:21 PM, William Gill wrote: I haven't done much with Python for a couple years, bouncing around between other languages and scripts as needs suggest, so I have some minor difficulty keeping Python functionality Python functionality in my head, but I can overcome that

Re: Help parsing a text file

2011-08-29 Thread William Gill
On 8/29/2011 2:31 PM, Philip Semanchuk wrote: If the syntax really is close to XML, would it be all that difficult to convert it to proper XML? Then you have nice libraries like ElementTree to use for parsing. Possibly, but I would still need the same search algorithms to find the opening

Re: Help parsing a text file

2011-08-29 Thread Thomas Jollans
On 29/08/11 20:21, William Gill wrote: I haven't done much with Python for a couple years, bouncing around between other languages and scripts as needs suggest, so I have some minor difficulty keeping Python functionality Python functionality in my head, but I can overcome that as the cobwebs

Re: python and parsing an xml file

2011-02-22 Thread Paul Anton Letnes
Den 21.02.11 18.30, skrev Matt Funk: Hi, I was wondering if someone had some advice: I want to create a set of xml input files to my code that look as follows: ?xml version=1.0 encoding=UTF-8? !-- Settings for the algorithm to be performed -- Algorithm

Re: python and parsing an xml file

2011-02-22 Thread Stefan Behnel
Matt Funk, 21.02.2011 23:08: On 2/21/2011 11:22 AM, Terry Reedy wrote: On 2/21/2011 12:30 PM, Matt Funk wrote: Hi, I was wondering if someone had some advice: I want to create a set of xml input files to my code that look as follows: Why? mmmh. not sure how to answer this question exactly.

Re: python and parsing an xml file

2011-02-22 Thread Ian
On 21/02/2011 22:08, Matt Funk wrote: Why? mmmh. not sure how to answer this question exactly. I guess it's a design decision. I am not saying that it is best one, but it seemed suitable to me. I am certainly open to suggestions. But here are some requirements: 1) My boss needs to be able to

Re: python and parsing an xml file

2011-02-22 Thread python
Paul, How about skipping the whole xml thing? You can dynamically import any python module, even if it does not have a python filename. Great example! Can you do the same with a cStringIO based file that exists in memory vs. on disk? Your example requires a physical file on disk. Is it

Re: python and parsing an xml file

2011-02-22 Thread Paul Anton Letnes
Den 22.02.11 13.29, skrev pyt...@bdurham.com: Paul, How about skipping the whole xml thing? You can dynamically import any python module, even if it does not have a python filename. Great example! Can you do the same with a cStringIO based file that exists in memory vs. on disk? Your

Re: python and parsing an xml file

2011-02-22 Thread Matt Funk
Hi, first of all thanks everyone for the (at least to me) valuable discussion about xml and its usage domain. Also thanks for all the hints and suggestions. In terms of my problems, from what i can tell right now the ConfigObj4 (see:

Re: python and parsing an xml file

2011-02-22 Thread Matt Funk
One thing i forgot, in case anyone is at this point: the reason i chose ConfigObj over ConfigParser is that it allows subsections. matt On 2/22/2011 4:01 AM, Ian wrote: On 21/02/2011 22:08, Matt Funk wrote: Why? mmmh. not sure how to answer this question exactly. I guess it's a design

Re: python and parsing an xml file

2011-02-22 Thread John Nagle
On 2/21/2011 2:08 PM, Matt Funk wrote: Hi Terry, On 2/21/2011 11:22 AM, Terry Reedy wrote: On 2/21/2011 12:30 PM, Matt Funk wrote: Hi, I was wondering if someone had some advice: I want to create a set of xml input files to my code that look as follows: Why? mmmh. not sure how to answer

Re: python and parsing an xml file

2011-02-22 Thread Stefan Behnel
John Nagle, 22.02.2011 23:56: On 2/21/2011 2:08 PM, Matt Funk wrote: On 2/21/2011 11:22 AM, Terry Reedy wrote: On 2/21/2011 12:30 PM, Matt Funk wrote: Hi, I was wondering if someone had some advice: I want to create a set of xml input files to my code that look as follows: Why? mmmh. not

python and parsing an xml file

2011-02-21 Thread Matt Funk
Hi, I was wondering if someone had some advice: I want to create a set of xml input files to my code that look as follows: ?xml version=1.0 encoding=UTF-8? !-- Settings for the algorithm to be performed -- Algorithm !-- The

Re: python and parsing an xml file

2011-02-21 Thread Stefan Behnel
Matt Funk, 21.02.2011 18:30: I want to create a set of xml input files to my code that look as follows: ?xml version=1.0 encoding=UTF-8? !-- Settings for the algorithm to be performed -- Algorithm !-- The algorithm type.

Re: python and parsing an xml file

2011-02-21 Thread Terry Reedy
On 2/21/2011 12:30 PM, Matt Funk wrote: Hi, I was wondering if someone had some advice: I want to create a set of xml input files to my code that look as follows: Why? ... So there are comments, whitespace etc ... in it. I would like to be able to put everything into some sort of structure

Re: python and parsing an xml file

2011-02-21 Thread Stefan Behnel
Terry Reedy, 21.02.2011 19:22: On 2/21/2011 12:30 PM, Matt Funk wrote: Hi, I was wondering if someone had some advice: I want to create a set of xml input files to my code that look as follows: Why? ... So there are comments, whitespace etc ... in it. I would like to be able to put

Re: python and parsing an xml file

2011-02-21 Thread Matt Funk
Hi Terry, On 2/21/2011 11:22 AM, Terry Reedy wrote: On 2/21/2011 12:30 PM, Matt Funk wrote: Hi, I was wondering if someone had some advice: I want to create a set of xml input files to my code that look as follows: Why? mmmh. not sure how to answer this question exactly. I guess it's a

Re: python and parsing an xml file

2011-02-21 Thread Matt Funk
HI Stefan, thank you for your advice. I am running into an issue though (which is likely a newbie problem): My xml file looks like (which i got from the internet): ?xml version=1.0? catalog book id=bk101 authorGambardella, Matthew/author titleXML Developer's Guide/title

Re: python and parsing an xml file

2011-02-21 Thread Matt Funk
Hi Stefan, i don't mean to be annoying so sorry if i am. According to your instructions i do: parser = objectify.makeparser(ns_clean=True, remove_comments=True) root = objectify.parse(inputfile,parser).getroot() print root.catalog.book.author.text which still gives the following error:

Re: python and parsing an xml file

2011-02-21 Thread Stefan Behnel
Matt Funk, 21.02.2011 23:07: thank you for your advice. I am running into an issue though (which is likely a newbie problem): My xml file looks like (which i got from the internet): ?xml version=1.0? catalog book id=bk101 authorGambardella, Matthew/author titleXML Developer's

Re: python and parsing an xml file

2011-02-21 Thread Stefan Behnel
Matt Funk, 21.02.2011 23:40: On 2/21/2011 3:28 PM, Stefan Behnel wrote: Matt Funk, 21.02.2011 23:07: thank you for your advice. I am running into an issue though (which is likely a newbie problem): My xml file looks like (which i got from the internet): ?xml version=1.0? catalog book

Re: HTMLParser not parsing whole html file

2010-10-26 Thread John Nagle
On 10/24/2010 11:44 PM, Stefan Behnel wrote: josh logan, 25.10.2010 04:14: I found the error. The HTML file I'm parsing has invalid HTML at line 193. It has something like: a href=mystuff class = stuff Note there is no space between the closing quote for the href tag and the class attribute

Re: HTMLParser not parsing whole html file

2010-10-25 Thread Stefan Behnel
josh logan, 25.10.2010 04:14: I found the error. The HTML file I'm parsing has invalid HTML at line 193. It has something like: a href=mystuff class = stuff Note there is no space between the closing quote for the href tag and the class attribute. I guess I'll go through each file and correct

HTMLParser not parsing whole html file

2010-10-24 Thread josh logan
Hello, I wanted to use python to scrub an html file for score data, but I'm having trouble. I'm using HTMLParser, and the parsing seems to fizzle out around line 192 or so. None of the event functions are being called anymore (handle_starttag, handle_endtag, etc.) and I don't understand why,

Re: HTMLParser not parsing whole html file

2010-10-24 Thread josh logan
On Oct 24, 4:36 pm, josh logan dear.jay.lo...@gmail.com wrote: Hello, I wanted to use python to scrub an html file for score data, but I'm having trouble. I'm using HTMLParser, and the parsing seems to fizzle out around line 192 or so. None of the event functions are being called anymore

Re: HTMLParser not parsing whole html file

2010-10-24 Thread josh logan
doesn't like how i surrounded the Python code's pastebin URL with parentheses: http://pastebin.com/HxwRTqrr I found the error. The HTML file I'm parsing has invalid HTML at line 193. It has something like: a href=mystuff class = stuff Note there is no space between the closing quote

Re: Parsing of a file

2008-08-07 Thread Bruno Desthuilliers
Tommy Grav a écrit : I have a file with the format Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames 5 Set 1 Field f31448: Ra=20:24:58.13 Dec=+79:39:43.9 MJD=53370.06811620 Frames 5 Set 2 Field f31226: Ra=20:24:45.50 Dec=+78:26:45.2 MJD=53370.06823860 Frames 5 Set 3

Re: Parsing of a file

2008-08-07 Thread Mike Driscoll
On Aug 6, 4:06 pm, John Machin [EMAIL PROTECTED] wrote: On Aug 7, 6:02 am, Mike Driscoll [EMAIL PROTECTED] wrote: On Aug 6, 1:55 pm, Tommy Grav [EMAIL PROTECTED] wrote: I have a file with the format Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames 5 Set 1

Re: Parsing of a file

2008-08-07 Thread Tommy Grav
On Aug 7, 2008, at 12:52 PM, Mike Driscoll wrote: I'm well aware of the split() method and built-ins, however since this appeared to be a homework-type question and I was at work, I didn't spend any time on the issue. The only reason I mentioned McGuire's PyParsing module was because I had just

Parsing of a file

2008-08-06 Thread Tommy Grav
I have a file with the format Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames 5 Set 1 Field f31448: Ra=20:24:58.13 Dec=+79:39:43.9 MJD=53370.06811620 Frames 5 Set 2 Field f31226: Ra=20:24:45.50 Dec=+78:26:45.2 MJD=53370.06823860 Frames 5 Set 3 Field f31004:

Re: Parsing of a file

2008-08-06 Thread Mike Driscoll
On Aug 6, 1:55 pm, Tommy Grav [EMAIL PROTECTED] wrote: I have a file with the format Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames   5 Set 1 Field f31448: Ra=20:24:58.13 Dec=+79:39:43.9 MJD=53370.06811620 Frames   5 Set 2 Field f31226: Ra=20:24:45.50 Dec=+78:26:45.2

Re: Parsing of a file

2008-08-06 Thread Shawn Milochik
I would like to parse this file by extracting the field id, ra, dec and mjd for each line. It is not, however, certain that the width of each value of the field id, ra, dec or mjd is the same in each line. Is there a way to do this such that even if there was a line Regular expressions will

Re: Parsing of a file

2008-08-06 Thread Stefan Behnel
Shawn Milochik wrote: I would like to parse this file by extracting the field id, ra, dec and mjd for each line. It is not, however, certain that the width of each value of the field id, ra, dec or mjd is the same in each line. Is there a way to do this such that even if there was a line

Re: Parsing of a file

2008-08-06 Thread John Machin
On Aug 7, 6:02 am, Mike Driscoll [EMAIL PROTECTED] wrote: On Aug 6, 1:55 pm, Tommy Grav [EMAIL PROTECTED] wrote: I have a file with the format Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames 5 Set 1 Field f31448: Ra=20:24:58.13 Dec=+79:39:43.9 MJD=53370.06811620

Re: Parsing of a file

2008-08-06 Thread bearophileHUGS
Using something like PyParsing is probably better, but if you don't want to use it you may use something like this: raw_data = Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames 5 Set 1 Field f31448: Ra=20:24:58.13 Dec=+79:39:43.9 MJD=53370.06811620 Frames 5 Set 2 Field

Re: Parsing of a file

2008-08-06 Thread John Machin
On Aug 7, 7:06 am, John Machin [EMAIL PROTECTED] wrote: On Aug 7, 6:02 am, Mike Driscoll [EMAIL PROTECTED] wrote: On Aug 6, 1:55 pm, Tommy Grav [EMAIL PROTECTED] wrote: I have a file with the format Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames 5 Set 1

Re: Parsing of a file

2008-08-06 Thread Henrique Dante de Almeida
On Aug 6, 3:55 pm, Tommy Grav [EMAIL PROTECTED] wrote: I have a file with the format Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames   5 Set 1 Field f31448: Ra=20:24:58.13 Dec=+79:39:43.9 MJD=53370.06811620 Frames   5 Set 2 Field f31226: Ra=20:24:45.50 Dec=+78:26:45.2

Re: Parsing of a file

2008-08-06 Thread Paul McGuire
On Aug 6, 3:14 pm, Shawn Milochik [EMAIL PROTECTED] wrote: Regular expressions will do the trick nicely. Or just use str.split, and create dicts using dict(list_of_tuples) constructor. This code creates a single dict for the input lines, keyed by id. Each value contains elements labeled 'id',

Re: Parsing of a file

2008-08-06 Thread bearophileHUGS
Paul McGuire: This code creates a single dict for the input lines, keyed by id. Each value contains elements labeled 'id', 'ra', and 'mjd'. ... d = dict( (rec.split()[1][:-1], dict([('id',rec.split()[1][:-1])] + [map(str.lower,f.split('='))

Re: Help Parsing an HTML File

2008-02-16 Thread Peter Otten
Stefan Behnel wrote: [EMAIL PROTECTED] wrote: I have a single unicode file that has descriptions of hundreds of objects. The file fairly resembles HTML-EXAMPLE pasted below. I need to parse the file in such a way to extract data out of the html and to come up with a tab separated file

Re: Help Parsing an HTML File

2008-02-16 Thread Paul McGuire
On Feb 15, 3:28 pm, [EMAIL PROTECTED] wrote: Hello Python Community, It'd be great if someone could provide guidance or sample code for accomplishing the following: I have a single unicode file that has  descriptions of hundreds of objects. The file fairly resembles HTML-EXAMPLE pasted

Re: Help Parsing an HTML File

2008-02-15 Thread Mike Driscoll
On Feb 15, 3:28 pm, [EMAIL PROTECTED] wrote: Hello Python Community, It'd be great if someone could provide guidance or sample code for accomplishing the following: I have a single unicode file that has descriptions of hundreds of objects. The file fairly resembles HTML-EXAMPLE pasted

Help Parsing an HTML File

2008-02-15 Thread egonslokar
Hello Python Community, It'd be great if someone could provide guidance or sample code for accomplishing the following: I have a single unicode file that has descriptions of hundreds of objects. The file fairly resembles HTML-EXAMPLE pasted below. I need to parse the file in such a way to

Re: Help Parsing an HTML File

2008-02-15 Thread Tim Chase
I need to parse the file in such a way to extract data out of the html and to come up with a tab separated file that would look like OUTPUT- FILE below. BeautifulSoup[1]. Your one-stop-shop for all your HTML parsing needs. What you do with the parsed data, is an exercise left to the reader,

Re: Help Parsing an HTML File

2008-02-15 Thread 7stud
On Feb 15, 2:28 pm, [EMAIL PROTECTED] wrote: Hello Python Community, It'd be great if someone could provide guidance or sample code for accomplishing the following: I have a single unicode file that has  descriptions of hundreds of objects. The file fairly resembles HTML-EXAMPLE pasted

Re: Help Parsing an HTML File

2008-02-15 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: I have a single unicode file that has descriptions of hundreds of objects. The file fairly resembles HTML-EXAMPLE pasted below. I need to parse the file in such a way to extract data out of the html and to come up with a tab separated file that would look like

Re: parsing a dbIII file

2007-08-08 Thread korovev76
On 7 Ago, 17:47, Jerry Hill [EMAIL PROTECTED] wrote: On 8/7/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have to parse a file (that is a dbIII file) whose stucture look like this: |string|, |string|, |string that may contain commas inside|, 1, 2, 3, | other string| The CSV module

parsing a dbIII file

2007-08-07 Thread korovev76
Hello everybody, I'm new to python (...I work with cobol...) I have to parse a file (that is a dbIII file) whose stucture look like this: |string|, |string|, |string that may contain commas inside|, 1, 2, 3, | other string| Is there anything in python that parses this stuff? thanks a lot

Re: parsing a dbIII file

2007-08-07 Thread Steve Holden
[EMAIL PROTECTED] wrote: Hello everybody, I'm new to python (...I work with cobol...) I have to parse a file (that is a dbIII file) whose stucture look like this: |string|, |string|, |string that may contain commas inside|, 1, 2, 3, | other string| Is there anything in python that parses

Re: parsing a dbIII file

2007-08-07 Thread korovev76
On 7 Ago, 09:21, Steve Holden [EMAIL PROTECTED] wrote: That's not a standard dBaseIII data file though, correct? It looks more like something that was produced *from* a dBaseIII file. yeap... unfortunately it is not... Good luck with your escape from COBOL! i'm not escaping by now...

Re: parsing a dbIII file

2007-08-07 Thread Jay Loden
[EMAIL PROTECTED] wrote: Hello everybody, I'm new to python (...I work with cobol...) I have to parse a file (that is a dbIII file) whose stucture look like this: |string|, |string|, |string that may contain commas inside|, 1, 2, 3, | other string| There are a number of relatively simple

Re: parsing a dbIII file

2007-08-07 Thread Paul McGuire
On Aug 7, 2:21 am, Steve Holden [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hello everybody, I'm new to python (...I work with cobol...) I have to parse a file (that is a dbIII file) whose stucture look like this: |string|, |string|, |string that may contain commas inside|, 1, 2,

Re: parsing a dbIII file

2007-08-07 Thread Jerry Hill
On 8/7/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have to parse a file (that is a dbIII file) whose stucture look like this: |string|, |string|, |string that may contain commas inside|, 1, 2, 3, | other string| The CSV module is probably the easiest way to go: data = |string|,

Parsing a setup file

2007-04-03 Thread Tommy Grav
Hi, I have a setup file for some numerical simulation code written in C that looks like this: dt 0.1 time 0.0 nupdate 10 noutput 100 ntotal 1 G 39.476926421373015 Sun 1.0597682 mplanet 9.547861040430418e-4 3.409530427945 3.635870038323 .03424028779975 -2.0471057839802485

Re: Parsing a setup file

2007-04-03 Thread James Stroud
Tommy Grav wrote: Hi, I have a setup file for some numerical simulation code written in C that looks like this: dt 0.1 time 0.0 nupdate 10 noutput 100 ntotal 1 G 39.476926421373015 Sun 1.0597682 mplanet 9.547861040430418e-4 3.409530427945 3.635870038323 .03424028779975

Progress when parsing a large file with SAX

2007-02-12 Thread marc . omorain
Hi there, I have a 28mb XML file which I parse with SAX. I have some processing to do in the startElement / endElement callbacks, which slows the parsing down to about 60 seconds on my machine. My application is unresponsive for this time, so I would like to show a progress bar. I could show a

Re: Progress when parsing a large file with SAX

2007-02-12 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: Hi there, I have a 28mb XML file which I parse with SAX. I have some processing to do in the startElement / endElement callbacks, which slows the parsing down to about 60 seconds on my machine. My application is unresponsive for this time, so I would like to show

Re: Progress when parsing a large file with SAX

2007-02-12 Thread Anastasios Hatzis
Diez B. Roggisch wrote: ... I got the same problem with large XML as Marc. So you deserve also my thanks for the example. :-) class PercentageFile(object): def __init__(self, filename): self.size = os.stat(filename)[6] self.delivered = 0 self.f = file(filename)

Re: Progress when parsing a large file with SAX

2007-02-12 Thread Diez B. Roggisch
Anastasios Hatzis wrote: Diez B. Roggisch wrote: ... I got the same problem with large XML as Marc. So you deserve also my thanks for the example. :-) class PercentageFile(object): def __init__(self, filename): self.size = os.stat(filename)[6] self.delivered = 0

Re: Progress when parsing a large file with SAX

2007-02-12 Thread marc . omorain
On Feb 12, 1:21 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Anastasios Hatzis wrote: Diez B. Roggisch wrote: Thanks guys! I'll try it out later today and let you know how I get on. -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing a log file

2005-08-14 Thread Andreas Kostyrka
Am Samstag, den 13.08.2005, 14:01 -0700 schrieb CG: Well, you have described your problem nicely. One thing that's missing is how to deal with incorrect input. (For example missing connect or disconnect messages). Furthermore, you can now: a) try to find somebody who writes it for you. How you

Re: Parsing a log file

2005-08-14 Thread John Machin
CG wrote: [snip] What I basically want to do is end up with a text file that can be easily imported into a database with a format like this (or I guess it could be written in a SQL script form that could write directly to a database like Mysql): Connect_Date Connect_Time Disconnect_date

Re: Parsing a log file

2005-08-14 Thread CG
Thanks Andreas, In your first paragraph, you ask about incorrect input. I guess it is possible, but without that information, my collection of the data is useless, so I really don't know what I would do with that. As for the other stuff, I can hack the data in other ways, such as with VBA and

Re: Parsing a log file

2005-08-14 Thread CG
John, Your comments are very helpful. I will take the datetime stamp as the way to go. I don't have a need to throw away the time info, it is You said: What do you do if servers are in different timezones? This is all inhouse in a non-daylight savings country and would not be an issue You

Re: Parsing a log file

2005-08-14 Thread googleboy
I am similarly not a programmer but am trying to learn python to do tasks like this. I would read through the regular expressions tutorial. You could probably easily read in all teh lines of the log file, and then split them up by (spaces).. If you're right about the lines all being

Re: Parsing a log file

2005-08-14 Thread Andreas Kostyrka
Completly untested: #!/usr/bin/env python import sys, datetime user = sys.argv[1] starttime = None for l in sys.stdin: flds = l.strip().split() datestr, timestr, prog, op, to, sname = flds month, day, year = [int(x) for x in datestr.split(-, 2)] hour, min, sec, ms = [int(x) for

Re: Parsing a log file

2005-08-14 Thread Andreas Kostyrka
Completly untested: #!/usr/bin/env python import sys, datetime user = sys.argv[1] starttime = None for l in sys.stdin: flds = l.strip().split() datestr, timestr, prog, op, to, sname = flds month, day, year = [int(x) for x in datestr.split(-, 2)] hour, min, sec, ms = [int(x) for

Parsing a log file

2005-08-13 Thread CG
I am looking for a way to parse a simple log file to get the information in a format that I can use. I would like to use python, but I am just beginning to learn how to use it. I am not a programmer, but have done some simple modifications and revisions of scripts. I am willing to attempt this