Jeff spotted it. Here's the corrected script, which now parses the data:
def CalculateSquidIpHits(logfile_pathname): # Make a dictionary to store IP addresses and their hit counts # and read the contents of the log file line by line IpHitListing = {} Contents = open(logfile_pathname, "r").xreadlines() #file_object = open(logfile_pathname) #Contents = list(file_object) # Go through each line of the logfile for line in Contents: # Split the string to isolate IP address Ip = line.split()[2] # Ensure length is proper if 6 < len(Ip) <= 15: # Increase by 1 if Ip exists; else set hit count = 1 IpHitListing[Ip] = IpHitListing.get(Ip, 0) + 1 return IpHitListing def main(): import sys if len(sys.argv)>=2: HitsDictionary = CalculateSquidIpHits(sys.argv[1]) for key in HitsDictionary.keys(): print key, '\t', HitsDictionary[key] else: print "Usage: CalculateSquidIpHits [Logfile]" if __name__ == '__main__': main() _______________________________________________ ActivePython mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython