Running Python Scripts

From Staffwiki

(Difference between revisions)
Jump to: navigation, search
Delonix (Talk | contribs)
(Created page with '== Install the Python Language Interpreter == Obtain the Windows self extracting installation file from [http://www.python.org/download/ Interpreter Downloads], choosing the Pyt…')
Newer edit →

Revision as of 16:52, 12 November 2009

Contents

Install the Python Language Interpreter

Obtain the Windows self extracting installation file from Interpreter Downloads, choosing the Python 2.6.4 Windows binary

When Windows prompts, Run the interpreter taking all defaults. This will leave an executable file "python.exe" in C:\python26\python.exe.

You will use this from the command line if you are running a program rather than developing a script. The IDLE platform (or a full featured editor such as EMACS) is a valuable structured development environment.

Example: Running a Previously Developed Script with Data

In this example, a script named "word2xls.py" has already been created. The script reads a text file with label:value data and rotates these data to produce a spreadsheet. The labels are column labels and these are as many rows as sets of unique labels. Complete data are assumed, though some attempt is made to allow for missing data.

Example Input File

Author: Emily Bronte Title: Wuthering Heights Publisher: Random House

Author: Samuel Clemens Title: Tom Sawyer Publisher: Knopf

Example Output File (from running the script)

Author Title Publisher
Emily Bronte Wuthering Heights Random House
Samuel Clemens Tom Sawyer Knopf
Personal tools