Re: [Tutor] parse text file

2010-06-03 Thread Steven D'Aprano
On Fri, 4 Jun 2010 12:45:52 am Colin Talbert wrote: > I thought when you did a for uline in input_file each single line > would go into memory independently, not the entire file. for line in file: reads one line at a time, but file.read() tries to read everything in one go. However, it should f

Re: [Tutor] parse text file

2010-06-03 Thread Sander Sweers
On 3 June 2010 21:02, Colin Talbert wrote: > I couldn't find any example of it in use and wasn't having any luck getting > it to work based on the documentation. Good examples of the bz2 module can be found at [1]. greets Sander [1] http://www.doughellmann.com/PyMOTW/bz2/

Re: [Tutor] parse text file

2010-06-03 Thread Vincent Davis
gt; (970) 226-9425 > talbe...@usgs.gov > > > > From: Dave Angel To: > Colin Talbert > Cc: Steven D'Aprano , tutor@python.org Date: 06/03/2010 > 12:36 PM Subject: Re: [Tutor] parse text file > -- > > > > Colin Talbert wrote:

Re: [Tutor] parse text file

2010-06-03 Thread Colin Talbert
rt Collins Science Center 2150 Centre Ave. Bldg. C Fort Collins, CO 80526 (970) 226-9425 talbe...@usgs.gov From: Dave Angel To: Colin Talbert Cc: Steven D'Aprano , tutor@python.org Date: 06/03/2010 12:36 PM Subject: Re: [Tutor] parse text file Colin Talbert wrote: > > You are

Re: [Tutor] parse text file

2010-06-03 Thread Dave Angel
Colin Talbert wrote: You are so correct. I'd been trying numerous things to read in this file and had deleted the code that I meant to put here and so wrote this from memory incorrectly. The code that I wrote should have been: import bz2 input_file = bz2.BZ2File(r'C:\temp\planet-latest.osm

Re: [Tutor] parse text file

2010-06-03 Thread Alan Gauld
"Colin Talbert" wrote I thought when you did a for uline in input_file each single line would go into memory independently, not the entire file. Thats true but your code snippet showed you using read() which reads the whole file... I'm pretty sure that this is not your code, because you ca

Re: [Tutor] parse text file

2010-06-03 Thread Colin Talbert
ogical Survey - Fort Collins Science Center 2150 Centre Ave. Bldg. C Fort Collins, CO 80526 (970) 226-9425 talbe...@usgs.gov From: Steven D'Aprano To: tutor@python.org Date: 06/02/2010 03:42 PM Subject: Re: [Tutor] parse text file Sent by: tutor-bounces+talbertc=usgs@python.org Hi

Re: [Tutor] parse text file

2010-06-02 Thread Steven D'Aprano
Hi Colin, I'm taking the liberty of replying to your message back to the list, as others hopefully may be able to make constructive comments. When replying, please ensure that you reply to the tutor mailing list rather than then individual. On Thu, 3 Jun 2010 12:20:10 am Colin Talbert wrote:

Re: [Tutor] parse text file

2010-06-02 Thread bob gailer
Colin Talbert GIS Specialist US Geological Survey - Fort Collins Science Center 2150 Centre Ave. Bldg. C Fort Collins, CO 80526 (970) 226-9425 talbe...@usgs.gov From: bob gailer To: Colin Talbert Cc: tutor@python.org Date: 06/01/2010 04:43 PM Subject: Re

Re: [Tutor] parse text file

2010-06-01 Thread Steven D'Aprano
On Wed, 2 Jun 2010 07:40:33 am Colin Talbert wrote: > I am also experiencing this same problem. (Also on a OSM bz2 > file). It appears to be working but then partway through reading a > file it simple ends. I did track down that file length is always > 90 so it appears to be related

Re: [Tutor] parse text file

2010-06-01 Thread bob gailer
On 6/1/2010 5:40 PM, Colin Talbert wrote: I am also experiencing this same problem. (Also on a OSM bz2 file). It appears to be working but then partway through reading a file it simple ends. I did track down that file length is always 90 so it appears to be related to some sort

Re: [Tutor] parse text file

2010-06-01 Thread Colin Talbert
I am also experiencing this same problem. (Also on a OSM bz2 file). It appears to be working but then partway through reading a file it simple ends. I did track down that file length is always 90 so it appears to be related to some sort of buffer constraint. Any other ideas? im

Re: [Tutor] parse text file

2010-02-03 Thread Norman Khine
On Tue, Feb 2, 2010 at 11:36 PM, Kent Johnson wrote: > On Tue, Feb 2, 2010 at 4:56 PM, Norman Khine wrote: >> On Tue, Feb 2, 2010 at 10:11 PM, Kent Johnson wrote: > >>> Try this version: >>> >>> data = file.read() >>> >>> get_records = re.compile(r"""openInfoWindowHtml\(.*?\ticon: >>> myIcon\n""

Re: [Tutor] parse text file

2010-02-03 Thread spir
On Tue, 2 Feb 2010 22:56:22 +0100 Norman Khine wrote: > i am no expert, but there seems to be a bigger difference. > > with repr(), i get: > Sat\\xe9re Maw\\xe9 > > where as you get > > Sat\xc3\xa9re Maw\xc3\xa9 > > repr()'s > é == \\xe9 > whereas on your version > é == \xc3\xa9 This is a ra

Re: [Tutor] parse text file

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 4:56 PM, Norman Khine wrote: > On Tue, Feb 2, 2010 at 10:11 PM, Kent Johnson wrote: >> Try this version: >> >> data = file.read() >> >> get_records = re.compile(r"""openInfoWindowHtml\(.*?\ticon: >> myIcon\n""", re.DOTALL).findall >> get_titles = re.compile(r"""(.*)<\/stro

Re: [Tutor] parse text file

2010-02-02 Thread Norman Khine
On Tue, Feb 2, 2010 at 10:11 PM, Kent Johnson wrote: > On Tue, Feb 2, 2010 at 1:39 PM, Norman Khine wrote: >> On Tue, Feb 2, 2010 at 4:19 PM, Kent Johnson wrote: >>> On Tue, Feb 2, 2010 at 9:33 AM, Norman Khine wrote: On Tue, Feb 2, 2010 at 1:27 PM, Kent Johnson wrote: > On Tue, Feb 2

Re: [Tutor] parse text file

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 1:39 PM, Norman Khine wrote: > On Tue, Feb 2, 2010 at 4:19 PM, Kent Johnson wrote: >> On Tue, Feb 2, 2010 at 9:33 AM, Norman Khine wrote: >>> On Tue, Feb 2, 2010 at 1:27 PM, Kent Johnson wrote: On Tue, Feb 2, 2010 at 4:16 AM, Norman Khine wrote: Why do you use

Re: [Tutor] parse text file

2010-02-02 Thread Norman Khine
On Tue, Feb 2, 2010 at 4:19 PM, Kent Johnson wrote: > On Tue, Feb 2, 2010 at 9:33 AM, Norman Khine wrote: >> On Tue, Feb 2, 2010 at 1:27 PM, Kent Johnson wrote: >>> On Tue, Feb 2, 2010 at 4:16 AM, Norman Khine wrote: >>> here are the changes: import re file=open('producers_g

Re: [Tutor] parse text file

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 9:33 AM, Norman Khine wrote: > On Tue, Feb 2, 2010 at 1:27 PM, Kent Johnson wrote: >> On Tue, Feb 2, 2010 at 4:16 AM, Norman Khine wrote: >> >>> here are the changes: >>> >>> import re >>> file=open('producers_google_map_code.txt', 'r') >>> data =  repr( file.read().decode

Re: [Tutor] parse text file

2010-02-02 Thread Norman Khine
hello, thank you all for the advise, here is the updated version with the changes. import re file = open('producers_google_map_code.txt', 'r') data = repr( file.read().decode('utf-8') ) get_records = re.compile(r"""openInfoWindowHtml\(.*?\\ticon: myIcon\\n""").findall get_titles = re.compile(r"""

Re: [Tutor] parse text file

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 4:16 AM, Norman Khine wrote: > here are the changes: > > import re > file=open('producers_google_map_code.txt', 'r') > data =  repr( file.read().decode('utf-8') ) Why do you use repr() here? > get_record = re.compile(r"""openInfoWindowHtml\(.*?\\ticon: myIcon\\n""") > get

Re: [Tutor] parse text file

2010-02-02 Thread Dave Angel
Norman Khine wrote: thanks denis, On Tue, Feb 2, 2010 at 9:30 AM, spir wrote: On Mon, 1 Feb 2010 16:30:02 +0100 Norman Khine wrote: On Mon, Feb 1, 2010 at 1:19 PM, Kent Johnson wrote: On Mon, Feb 1, 2010 at 6:29 AM, Norman Khine wrote: thanks, what about the whi

Re: [Tutor] parse text file

2010-02-02 Thread Stefan Behnel
Norman Khine, 02.02.2010 10:16: > get_record = re.compile(r"""openInfoWindowHtml\(.*?\\ticon: myIcon\\n""") > get_title = re.compile(r"""(.*)<\/strong>""") > get_url = re.compile(r"""a href=\"\/(.*)\">En savoir plus""") > get_latlng = re.compile(r"""GLatLng\((\-?\d+\.\d*)\,\\n\s*(\-?\d+\.\d*)\)""")

Re: [Tutor] parse text file

2010-02-02 Thread Norman Khine
thanks denis, On Tue, Feb 2, 2010 at 9:30 AM, spir wrote: > On Mon, 1 Feb 2010 16:30:02 +0100 > Norman Khine wrote: > >> On Mon, Feb 1, 2010 at 1:19 PM, Kent Johnson wrote: >> > On Mon, Feb 1, 2010 at 6:29 AM, Norman Khine wrote: >> > >> >> thanks, what about the whitespace problem? >> > >> >

Re: [Tutor] parse text file

2010-02-02 Thread spir
On Mon, 1 Feb 2010 16:30:02 +0100 Norman Khine wrote: > On Mon, Feb 1, 2010 at 1:19 PM, Kent Johnson wrote: > > On Mon, Feb 1, 2010 at 6:29 AM, Norman Khine wrote: > > > >> thanks, what about the whitespace problem? > > > > \s* will match any amount of whitespace includin newlines. > > thank y

Re: [Tutor] parse text file

2010-02-01 Thread Norman Khine
On Mon, Feb 1, 2010 at 1:19 PM, Kent Johnson wrote: > On Mon, Feb 1, 2010 at 6:29 AM, Norman Khine wrote: > >> thanks, what about the whitespace problem? > > \s* will match any amount of whitespace includin newlines. thank you, this worked well. here is the code: ### import re file=open('produ

Re: [Tutor] parse text file

2010-02-01 Thread Kent Johnson
On Mon, Feb 1, 2010 at 6:29 AM, Norman Khine wrote: > thanks, what about the whitespace problem? \s* will match any amount of whitespace includin newlines. Kent ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: htt

Re: [Tutor] parse text file

2010-02-01 Thread Norman Khine
On Mon, Feb 1, 2010 at 10:57 AM, spir wrote: > On Mon, 1 Feb 2010 00:43:59 +0100 > Norman Khine wrote: > >> but this does not take into account of data which has negative values > > just add \-? in front of \d+ thanks, what about the whitespace problem? > > Denis > _

Re: [Tutor] parse text file

2010-02-01 Thread spir
On Mon, 1 Feb 2010 00:43:59 +0100 Norman Khine wrote: > but this does not take into account of data which has negative values just add \-? in front of \d+ Denis la vita e estrany http://spir.wikidot.com/ ___ Tutor ma

Re: [Tutor] parse text file

2010-01-31 Thread Norman Khine
Hello, I am still unable to get this to work correctly! In [1]: file=open('producers_google_map_code.txt', 'r') In [2]: data = repr( file.read().decode('utf-8') ) In [3]: from BeautifulSoup import BeautifulStoneSoup In [4]: soup = BeautifulStoneSoup(data) In [6]: soup http://paste.lisp.org/d

Re: [Tutor] parse text file

2010-01-22 Thread Norman Khine
Hi On Fri, Jan 22, 2010 at 7:44 PM, spir wrote: > On Fri, 22 Jan 2010 14:11:42 +0100 > Norman Khine wrote: > >> but my problem comes when i try to list the GLatLng: >> >> GLatLng(9.696333, 122.985992); >> >> >>> StartingWithGLatLng = soup.findAll(re.compile('GLatLng')) >> >>> StartingWithGLatLng

[Tutor] parse text file

2010-01-22 Thread Norman Khine
Hello, I have the following http://paste.lisp.org/display/93732 txt file. >From this I would like to extract ... 'ACP' + 'En savoir plus' ); ... map.addOverlay(marqueur[1]);var latlng = new GLatLng(9.696333,

Re: [Tutor] Parse Text File

2009-06-11 Thread Stefan Lesicnik
> > Hi Denis, > > > > Thanks for your input. So i decided i should use a pyparser and try it > (im a > > relative python noob though!) > Hi Everyone! I have made some progress, although i believe it mainly due to luck and not a lot of understanding (vague understanding maybe). Hopefully this can

Re: [Tutor] Parse Text File

2009-06-11 Thread spir
[Hope you don't mind I copy to the list. Not only it can help others, but pyparsing users read tutor, including Paul MacGuire (author).] Le Thu, 11 Jun 2009 11:53:31 +0200, Stefan Lesicnik s'exprima ainsi: [...] I cannot really answer precisely for haven't used pyparsing for a while (*). So,

Re: [Tutor] Parse Text File

2009-06-10 Thread Eduardo Vieira
On Wed, Jun 10, 2009 at 12:44 PM, Stefan Lesicnik wrote: > Hi Guys, > > I have the following text > > [08 Jun 2009] DSA-1813-1 evolution-data-server - several vulnerabilities >     {CVE-2009-0547 CVE-2009-0582 CVE-2009-0587} >     [etch] - evolution-data-server 1.6.3-5etch2 >     [lenny

[Tutor] Parse Text File

2009-06-10 Thread Stefan Lesicnik
Hi Guys, I have the following text [08 Jun 2009] DSA-1813-1 evolution-data-server - several vulnerabilities {CVE-2009-0547 CVE-2009-0582 CVE-2009-0587} [etch] - evolution-data-server 1.6.3-5etch2 [lenny] - evolution-data-server 2.22.3-1.1+lenny1 [04 Jun 2009] DSA-1812-1 ap