O'Reilly logo

Python 2.6 Text Processing Beginner's Guide by Jeff McNeil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - generating transfer statistics

Now, let's start our processor. Initially, we'll build enough functionality to scan our logfile as read via standard input and report files served over a given size. System administrators may find utilities such as this useful when attempting to track down abusive users. It's also generally a good idea to iteratively add functionality to an application in development.

  1. First, step into the virtual environment created in Chapter 1, Getting Started and activate it so that all of our work is isolated locally. Only the UNIX method is shown here.
    
    $ cd text_processing/
    $ . bin/activate
    
  2. Create an empty Python file and name it logscan.py. Enter the following code:
     #!/usr/bin/python import sys from optparse ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required