Re: [Tutor] how to extract data only after a certain condition is met

2010-10-06 Thread Emile van Sebille
On 10/6/2010 11:58 AM Joel Goldstick said... On Wed, Oct 6, 2010 at 2:50 PM, Emile van Sebille wrote: On 10/6/2010 9:25 AM Eduardo Vieira said... Of course this solution is simpler: extracted = a[a.index("i")+1:] But I didn't want to build a list in memory with "readlines()" in the case

Re: [Tutor] how to extract data only after a certain condition is met

2010-10-06 Thread Joel Goldstick
On Wed, Oct 6, 2010 at 2:50 PM, Emile van Sebille wrote: > On 10/6/2010 9:25 AM Eduardo Vieira said... > > > > Of course this solution is simpler: >> extracted = a[a.index("i")+1:] >> But I didn't want to build a list in memory with "readlines()" in the >> case of a file. >> > > This is what I

Re: [Tutor] how to extract data only after a certain condition is met

2010-10-06 Thread Emile van Sebille
On 10/6/2010 9:25 AM Eduardo Vieira said... Of course this solution is simpler: extracted = a[a.index("i")+1:] But I didn't want to build a list in memory with "readlines()" in the case of a file. This is what I do unless the files are _really big_ For-me-really-big-is-over-200Mb-ish-ly y'rs

Re: [Tutor] how to extract data only after a certain condition is met

2010-10-06 Thread Alan Gauld
"Eduardo Vieira" wrote The other day I was writing a script to extract data from a file from the line where a text is found to the end of the file. The standard pattern here is to use a sentinel, in pseudo code: def checkLine(line, start='',end=''): if (start in line) or (end in line):

Re: [Tutor] Scrapy vs. Beautiful Soup

2010-10-06 Thread Alan Gauld
"Crusier" wrote I have also found that there is something called Scrapy. Please kindly comment on it. Which one is easier to use compared with Beautiful Soup? Well I can safely say that Beautiful Soup will be exactly the same as Beauitiful Soup to use! :-) As for scrapy I'd never heard of

Re: [Tutor] how to extract data only after a certain condition is met

2010-10-06 Thread Knacktus
Am 06.10.2010 18:25, schrieb Eduardo Vieira: The other day I was writing a script to extract data from a file from the line where a text is found to the end of the file. The same functionality is this sed script: '1,/regexp/'d I couldn't put my head to work around this and came up with a solution

[Tutor] pymssql and encoding

2010-10-06 Thread Emmanuel Ruellan
Hi tutors, I'm trying to fetch data from an MS SQL Server database with pymssql, but non-ascii results get garbled. >>> import pymssql >>> conn = pymssql.connect(user='sa', password=myPassword, host=server, database=targetDatabase, as_dict=True) >>> curs = conn.cursor() >>> curs.execute("select C

Re: [Tutor] how to extract data only after a certain condition is met

2010-10-06 Thread Peter Otten
Eduardo Vieira wrote: > The other day I was writing a script to extract data from a file from > the line where a text is found to the end of the file. The same > functionality is this sed script: > '1,/regexp/'d > I couldn't put my head to work around this and came up with a solution > using list

[Tutor] how to extract data only after a certain condition is met

2010-10-06 Thread Eduardo Vieira
The other day I was writing a script to extract data from a file from the line where a text is found to the end of the file. The same functionality is this sed script: '1,/regexp/'d I couldn't put my head to work around this and came up with a solution using list slicing. But how can I do that? I w

Re: [Tutor] EXECUTING PYTHON AND SQL STAMENTS

2010-10-06 Thread Norman Khine
hello On Tue, Oct 5, 2010 at 5:57 PM, Susana Iraiis Delgado Rodriguez wrote: > Hello, I already solved the problem, I change all the code, instead of using > os.system I changed to subprocess.Popen() and it worked fine: > import shlex, subprocess > def process(): > print "Ingresa en el sigui

Re: [Tutor] cgi help

2010-10-06 Thread delegbede
Got it fixed. Thanks y'all. Regards, --Original Message-- From: Dave Angel To: Dipo Elegbede Cc: tutor Subject: Re: [Tutor] cgi help Sent: Oct 6, 2010 12:30 On 2:59 PM, Dipo Elegbede wrote: > here is the code: > > http://pastebin.com/K2Fxq6ac > > kindly help me figure out my mistake. > >

Re: [Tutor] cgi help

2010-10-06 Thread Dave Angel
On 2:59 PM, Dipo Elegbede wrote: here is the code: http://pastebin.com/K2Fxq6ac kindly help me figure out my mistake. It is supposed to return a table of environmental variables but it returns only the header and a blank page. thanks Care to define "return" ? How are you running this cod

[Tutor] Scrapy vs. Beautiful Soup

2010-10-06 Thread Crusier
Hi Emile, I have also found that there is something called Scrapy. Please kindly comment on it. Which one is easier to use compared with Beautiful Soup? Thanks in advance. Cheers, Hank ___ Tutor maillist - Tutor@python.org To unsubscribe or change su

Re: [Tutor] CGI HELP

2010-10-06 Thread delegbede
Yes, so I did a pastebin and resent to the group. Thanks. Sent from my BlackBerry wireless device from MTN -Original Message- From: Joel Goldstick Sender: tutor-bounces+delegbede=dudupay@python.org Date: Wed, 6 Oct 2010 05:54:03 To: tutor Subject: Re: [Tutor] CGI HELP __

Re: [Tutor] CGI HELP

2010-10-06 Thread Joel Goldstick
On Wed, Oct 6, 2010 at 5:25 AM, Dipo Elegbede wrote: > Hi all, > > I wrote this code as an example from a book: > > #!c:\Python26\python.exe > # Program displaying CGI environment variables. > > import os > import cgi > > def printHeader(title): > print """Content-type: text/html > > > "-//W3C/

[Tutor] cgi help

2010-10-06 Thread Dipo Elegbede
here is the code: http://pastebin.com/K2Fxq6ac kindly help me figure out my mistake. It is supposed to return a table of environmental variables but it returns only the header and a blank page. thanks -- Elegbede Muhammed Oladipupo OCA +2348077682428 +2347042171716 www.dudupay.com Mobile Bank

[Tutor] CGI HELP

2010-10-06 Thread Dipo Elegbede
Hi all, I wrote this code as an example from a book: #!c:\Python26\python.exe # Program displaying CGI environment variables. import os import cgi def printHeader(title): print """Content-type: text/html http://www.w3.org/1999/xhtml";> %s """ % title rowNumber = 0 backgroundColour = "white

Re: [Tutor] specifying precision with scientific notation

2010-10-06 Thread ALAN GAULD
> But something like the "%.%de " %n is exactly what I am looking for - if I >could get it to work. Sorry my bad, I missed a % sign: >>> n=5 >>> "%%.%de" % n '%.5e' You need two %% to create a % in the output. Alan G. ___ Tutor maillist - Tut