473,804 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.p y", line 18, in
lijst.append(in t(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.sp lit(line)
datum=string.sp lit(words[3],':') # datum bevat de volledige datum:
[16/Sep/2003:05:22:57 +0200]
lijst.append(in t(datum[1]))

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

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

f.close()
Jul 18 '05 #1
2 1260
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.p y", line 18, in
lijst.append(in t(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
2930
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 database. The entries from the Albums011.txt look like this: Wayne Newton - Wild Cool & Swingin' - 03 - But Not For Me.mp3 Wayne Newton - Wild Cool & Swingin' - 04 - Wives And Lovers.mp3 etc. and I want to manipulate it them to look in the...
45
3054
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
8418
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: '@localhost' to database 'test1' Any help would be appreciated
0
1569
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 Aug 2003 15:39:54 -0700 From: Tiffany Wilkes <tdwilkes@ucdavis.edu> To: mysql@lists.mysql.com
6
2350
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 solution. My code can be downloaded from here: http://www.tprimke.net/konto/PyObject-problem.tar.bz2. There are some scripts for GNU/Linux system (bash to be precise). All you need to know is that there are four classes. (Of course, you may...
4
3314
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 superlist is always an integer
2
3569
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 instructions posted on the php.net web site but all my e-mails go unresponded to. I've tried contacting the webmaster as well as the admin address posted but all to no avail. I've tried using the link provided in each message to unsub but again no...
15
2100
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 have an XML file containing links and I use an XSL file to build a
2
2289
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 should; however, as soon as you mouse towards any but the TOP sub-catagory, all those sub-catagories still view there. It will work first time quite fine..but if user clicks outsite anywhere in screen then this problem occur.. i think it's css...
2
2318
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 <boost/graph/adjacency_list.hpp> #include <boost/tuple/tuple.hpp> #include <set> using namespace std;
0
9595
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10354
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10359
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10101
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6870
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3837
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3005
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.