Re: [Tutor] Tutor Digest, Vol 69, Issue 21 - Change a text string from a list and change it into an integer(WinXP/py2.6.2/Beginner)

2009-11-09 Thread Lie Ryan
Katt wrote: First I want to thank the following people for your help: Wayne W., Shashwat A., and Alan G. I appreciate the input/criticism as I continually learn more and more. It seems that I am not sure if I am posting correctly to the right thread and am not sure if it has to do with the f

Re: [Tutor] parsing XML

2009-11-09 Thread Alan Gauld
"Christopher Spears" wrote I need to parse several XML documents into a Python dictionary. Is there a module that would be particularly good for this? I heard beginners should start with ElementTree. However, SAX seems to make a little more sense to me. XML parsers fall into 2 groups

Re: [Tutor] parsing XML

2009-11-09 Thread Eric Pavey
On Mon, Nov 9, 2009 at 7:48 PM, Christopher Spears wrote: > Hi! > > I need to parse several XML documents into a Python dictionary. Is there a > module that would be particularly good for this? I heard beginners should > start with ElementTree. However, SAX seems to make a little more sense to

Re: [Tutor] Tutor Digest, Vol 69, Issue 21 - Change a text string from a list and change it into an integer(WinXP/py2.6.2/Beginner)

2009-11-09 Thread Shashwat Anand
On Tue, Nov 10, 2009 at 9:12 AM, Katt wrote: > First I want to thank the following people for your help: Wayne W., > Shashwat A., and Alan G. I appreciate the input/criticism as I continually > learn more and more. > > It seems that I am not sure if I am posting correctly to the right thread > a

[Tutor] parsing XML

2009-11-09 Thread Christopher Spears
Hi! I need to parse several XML documents into a Python dictionary. Is there a module that would be particularly good for this? I heard beginners should start with ElementTree. However, SAX seems to make a little more sense to me. Any suggestions? __

Re: [Tutor] Tutor Digest, Vol 69, Issue 21 - Change a text string from a list and change it into an integer(WinXP/py2.6.2/Beginner)

2009-11-09 Thread Katt
First I want to thank the following people for your help: Wayne W., Shashwat A., and Alan G. I appreciate the input/criticism as I continually learn more and more. It seems that I am not sure if I am posting correctly to the right thread and am not sure if it has to do with the fact that I am

Re: [Tutor] class initialization with a lot of parameters

2009-11-09 Thread Dave Angel
C.T. Matsumoto wrote: Hello All, I'm making a class and the parameters I'm feeding the class is getting quite large. I'm up to 8 now. Is there any rules of thumb for classes with a lot of parameters? I was thinking to put the parameters into a tuple and then in the __init__ of the class, iterate

Re: [Tutor] SQLite database not update correctly

2009-11-09 Thread Che M
> It's working fine now, but actually I didn't write exactly what you > suggested. > The "commit" method belongs to the connection, not to the cursor. Therefore, > in my script it should be conn.commit(). Whoops, you're quite right. Went a little too fast there. :D Che

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread ALAN GAULD
> > what the default python sorting algorithm is on a list, but AFAIK you'd be > > looking at a constant O(log 10) > > I'm not a mathematician - what does this mean, in layperson's terms? O(log10) is a way of expressing the efficiency of an algorithm. Its execution time is proportional (in the

Re: [Tutor] CGI Script Fails on import cgi

2009-11-09 Thread ALAN GAULD
Please use ReplyAll when replying to the list. And please do not hijack other threads, it confuses threaded mail tools/newsreaders. From: Keshav Inderjeet To: alan.ga...@btinternet.com Sent: Monday, 9 November, 2009 16:10:30 Subject: RE: [Tutor] CGI Script Fails on import cgi > In fact thes

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Stephen Nelson-Smith
On Mon, Nov 9, 2009 at 3:15 PM, Wayne Werner wrote: > On Mon, Nov 9, 2009 at 7:46 AM, Stephen Nelson-Smith > wrote: >> >> And the problem I have with the below is that I've discovered that the >> input logfiles aren't strictly ordered - ie there is variance by a >> second or so in some of the ent

Re: [Tutor] class initialization with a lot of parameters

2009-11-09 Thread Alan Gauld
"C.T. Matsumoto" wrote I'm making a class and the parameters I'm feeding the class is getting quite large. I'm up to 8 now. Is there any rules of thumb for classes with a lot of parameters? There are no rules as such. Some of the Tkinter classes for excample take a lot of arguments. But y

Re: [Tutor] CGI Script Fails on import cgi

2009-11-09 Thread Alan Gauld
"Kristin Wilcox" wrote Unfortunately, I error out whenever I do 'import cgi'. I'm hoping to receive some advice! Thanks in advance for reading all this. My guess is that your web server user id is not set up to find the Python modules. You probably need the admin to do some web config Bu

Re: [Tutor] Cramer's Rule

2009-11-09 Thread Alan Gauld
"Keshav Inderjeet" wrote Hello everyone I have been tryin to convert the following C- codes in python but always receiving error messages. Please Help. So give us a clue. What does your code look like? What errors are you getting? What do you think the problem might be? -- Alan Gauld A

[Tutor] Cramer's Rule

2009-11-09 Thread Keshav Inderjeet
Hello everyone I have been tryin to convert the following C- codes in python but always receiving error messages. Please Help. The program is about Cramer's rule #include #double finddet(double a1,double a2, double a3,double b1, double b2,double b3, double c1, double c2, double c3);

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread ALAN GAULD
> I can sort the biggest logfile (800M) using unix sort in about 1.5 > mins on my workstation. That's not really fast enough, with > potentially 12 other files You won't beat sort with Python. You have to be realistic, these are very big files! Python should be faster overall but for speci

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Wayne Werner
On Mon, Nov 9, 2009 at 7:46 AM, Stephen Nelson-Smith wrote: > And the problem I have with the below is that I've discovered that the > input logfiles aren't strictly ordered - ie there is variance by a > second or so in some of the entries. > Within a given set of 10 lines, is the first line and

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Stephen Nelson-Smith
And the problem I have with the below is that I've discovered that the input logfiles aren't strictly ordered - ie there is variance by a second or so in some of the entries. I can sort the biggest logfile (800M) using unix sort in about 1.5 mins on my workstation. That's not really fast enough,

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Stephen Nelson-Smith
Hi, > If you create iterators from the files that yield (timestamp, entry) > pairs, you can merge the iterators using one of these recipes: > http://code.activestate.com/recipes/491285/ > http://code.activestate.com/recipes/535160/ Could you show me how I might do that? So far I'm at the stage o

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Gerard Flanagan
Stephen Nelson-Smith wrote: Hi, Any advice or experiences? go here and download the pdf! http://www.dabeaz.com/generators-uk/ Someone posted this the other day, and I went and read through it and played around a bit and it's exactly what you're looking for - plus it has one vs. slid

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Stephen Nelson-Smith
Hi, >> Any advice or experiences? >> > > go here and download the pdf! > http://www.dabeaz.com/generators-uk/ > Someone posted this the other day, and I went and read through it and played > around a bit and it's exactly what you're looking for - plus it has one vs. > slide of python vs. awk. > I

[Tutor] class initialization with a lot of parameters

2009-11-09 Thread C.T. Matsumoto
Hello All, I'm making a class and the parameters I'm feeding the class is getting quite large. I'm up to 8 now. Is there any rules of thumb for classes with a lot of parameters? I was thinking to put the parameters into a tuple and then in the __init__ of the class, iterate over the tuple and assi

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Wayne Werner
On Sun, Nov 8, 2009 at 11:41 PM, Stephen Nelson-Smith wrote: > I've got a large amount of data in the form of 3 apache and 3 varnish > logfiles from 3 different machines. They are rotated at 0400. The > logfiles are pretty big - maybe 6G per server, uncompressed. > > I've got to produce a combin

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Kent Johnson
On Mon, Nov 9, 2009 at 4:36 AM, Stephen Nelson-Smith wrote: I want to extract 24 hrs of data based timestamps like this: [04/Nov/2009:04:02:10 +] >>> >>> OK It looks like you could use a regex to extract the first >>> thing you find between square brackets. Then convert that to a

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Martin A. Brown
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello, : An apache logfile entry looks like this: : : 89.151.119.196 - - [04/Nov/2009:04:02:10 +] "GET : /service.php?s=nav&arg[]=&arg[]=home&q=ubercrumb/node%2F20812 : HTTP/1.1" 200 50 "-" "-" : : I want to extract 24 hrs of data based t

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Stephen Nelson-Smith
Sorry - forgot to include the list. On Mon, Nov 9, 2009 at 9:33 AM, Stephen Nelson-Smith wrote: > On Mon, Nov 9, 2009 at 9:10 AM, ALAN GAULD wrote: >> >>> An apache logfile entry looks like this: >>> >>>89.151.119.196 - - [04/Nov/2009:04:02:10 +] "GET >>> /service.php?s=nav&arg[]=&arg[]=home

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread ALAN GAULD
> An apache logfile entry looks like this: > >89.151.119.196 - - [04/Nov/2009:04:02:10 +] "GET > /service.php?s=nav&arg[]=&arg[]=home&q=ubercrumb/node%2F20812 > HTTP/1.1" 200 50 "-" "-" > >I want to extract 24 hrs of data based timestamps like this: > > [04/Nov/2009:04:02:10 +] OK It lo

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Stephen Nelson-Smith
On Mon, Nov 9, 2009 at 8:47 AM, Alan Gauld wrote: > I'm not familiar with Apache log files so I'll let somebody else answer, > but I suspect you can either use string.split() or a re.findall(). You might > even be able to use csv. Or if they are in XML you could use ElementTree. > It all depends

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Alan Gauld
"Stephen Nelson-Smith" wrote * How does Python compare in performance to shell, awk etc in a big pipeline? The shell script kills the CPU Python should be significantly faster than the typical shell script and it should consume less resources, although it will probably still use a fair bit o

[Tutor] CGI Script Fails on import cgi

2009-11-09 Thread Kristin Wilcox
Hello, As I've mentioned on the list before, I'm very new to Python and programming in general. Now I'm trying my hand at writing very very simple CGI scripts. I basically wanted to try play with cgi scripting as I feel my way around Python. I'm uploading to my account on my university's server.