[Tutor] CUPS-page_log processing

Rudolf Maurer rudolf.maurer@lycos.de
Wed Jun 18 04:09:06 2003


Hi all,

i am dreaming of having a little Python-Script for searching of the
entries of a user or printer in CUPS page_log file. (Yes, I know the
large Python solution to this problem... pykota. But it has lots of
Overhead and that project teaches me Python :-) )

page_log uses the Common Log File Format of Apache. Is there a Module
which provides already a handling of this format?
Each entry is one line, with printer-name username, DateTime, number of
pages, status code

Now, i tried a little Program which is able to search for lines in that
file which belong to a printer. Then i do string.split() on the found
lines and end up with a list of strings for each line. Where to store
these lists? It might be a thousand or so. Dictionary, List, Tuple? How
about the consumption of memory?

Would you suggest to me reading all the file to memory (i.e. as a list
like: lines = file.readlines() ?
Or is it better to read each line, process an go to the next one ?
The file might have lots of lines...

What if i want to delete single lines out of the file? Does exist a
method for that? And where can i search for these method for miself (not
having to ask here every time...). I think i'm to dump to use the Python
Library Reference (if thats the right place...)

Thanks a lot for providing that great help!

See you
Rudy