473,395 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problem with lists

Hi,

I'm writing an application to analyse my Apache access_log file. In
the below script (which is based on an example I found in 'How to
think as a Programmer'-) I want to measure the amount of hits per
hour. I know it is not the best algorithm but it works for now.

I see some strange things: on rather small (it must be +/- < 4000 )
entries in the access_log, my script works fine. Above this limit, I
get the following error.

Traceback (most recent call last):
File "hits_per_uur.py", line 18, in
lijst.append(int(datum[1]))
IndexError: list index out of range

Question: do lists have a limit? Anyone know how I can change this
simple script so that it works for more entries as well.

------------------------------------------------------------------------------
import sys,string

def inbucket(lijst, low, high):
count=0
for num in lijst:
if low<=num<high:
count=count+1
return count

f=open('c:/summary.txt','a',1)
f.write("Hits per uur" + "\n")

lijst=['']*0
data=sys.stdin.readlines()
for line in data:
words=string.split(line)
datum=string.split(words[3],':') # datum bevat de volledige datum:
[16/Sep/2003:05:22:57 +0200]
lijst.append(int(datum[1]))

numbuckets=24
buckets= [0]*numbuckets
bucketwidth=24/numbuckets
for i in range(numbuckets):
low=i* bucketwidth
high=low+bucketwidth
buckets[i]=inbucket(lijst,low,high)

for num in range(len(buckets)):
output=str(num) + "\t" + str(buckets[num]) + "\n"
f.write(output)

f.close()
Jul 18 '05 #1
2 1250
WIWA wrote:
Hi,

I'm writing an application to analyse my Apache access_log file. In
the below script (which is based on an example I found in 'How to
think as a Programmer'-) I want to measure the amount of hits per
hour. I know it is not the best algorithm but it works for now.

I see some strange things: on rather small (it must be +/- < 4000 )
entries in the access_log, my script works fine. Above this limit, I
get the following error.

Traceback (most recent call last):
File "hits_per_uur.py", line 18, in
lijst.append(int(datum[1]))
IndexError: list index out of range


The error could be in datum[1]. Did you double-check that datum has at
least two elements?

David

Jul 18 '05 #2
WIWA wrote:
I see some strange things: on rather small (it must be +/- < 4000 )
entries in the access_log, my script works fine. Above this limit, I
get the following error.
It probably means that there's an entry in the log that isn't what you
expect. The error is being generated by the input data; print the
contents of `datum' before you run that code, or check it out in a
debugger, to see what it contains.
Question: do lists have a limit? Anyone know how I can change this
simple script so that it works for more entries as well.


No, lists do not have any such limitation. The code that's generation
the exception isn't dealing with a large list, anyway.

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ It's just a day that brings it all about
\__/ Sade
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: JDJones | last post by:
I'm trying to write a script that will read from a text list of songs that I burned onto my CD (Albums011.txt), then write to the database text the new text made ready for inserting into a...
45
by: Joh | last post by:
hello, i'm trying to understand how i could build following consecutive sets from a root one using generator : l = would like to produce : , , , ,
0
by: Didier ROS | last post by:
Hi, I am a newbie I want to create a temporary table and I get the following error message : mysql> CREATE TEMPORARY TABLE tempemp AS SELECT * FROM emp; ERROR 1044: Access denied for user:...
0
by: Tiffany Wilkes | last post by:
I solved the problem--I needed ( ) around the column list. I think the manual should make that more clear. -------- Original Message -------- Subject: column privilege problem Date: Tue, 05...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
4
by: flamesrock | last post by:
Kind of a fun but confusing problem... I have two lists. Each list contains elements of two-element lists. l1 = ,,] l2 = ,,,] Exactly in this format, where superlist is always a string...
2
by: Cox | last post by:
Hello: My address jsmith435@cox.net is subscribed to at least the PHP General mailing list. I have for days now been trying to unsubscribe from all PHP mail lists. I have followed the...
15
by: lucky | last post by:
Hi Guys You are probably my last chance to avoid getting crazy To help you understand my problem I have put images online showing the issue I have: http://www.australix.net/images/pb I...
2
by: Ravi Joshi | last post by:
The menu on my site works fine in IE6 and Firefox. In IE7, there is a problem with the menu: when you mouse over the various main catagories, the sub-catagories all appear to the right as they...
2
by: Man4ish | last post by:
I have created Graph object without vertex and edge property.It is working fine. #include <boost/config.hpp> #include <iostream> #include <vector> #include <string> #include...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.