Name: [002] Ian Ozsvald
Member: 128 months
Authored: 181 videos
Description: I am the co-founder of ShowMeDo (see, author of `The Screencasting Handbook <>`_ and the founder of the professional screencast production company `ProCasts <>`_: .. image:: ...

Python 101 - easygui and csv [ID:091]

a series of video-tutorials by Ian Ozsvald

Aimed at Python Beginner Programmers, this fully-worked series builds a complete application that utilises a User Interface, the comma-separated-values (csv) module, reads and writes files, handles exceptions and gives useful error messages, uses test-driven development, nosetests and refactoring. We do all of this inside Wingware's excellent Wing IDE.

"Very well explained. I've learned a lot about debugging code. The ability to print the code, work through the problem and review the screencast, makes for clear understanding of what's going on. Thanks." - Jshack
"It's a NO BRAINER to get this quality of tutorial [...]. Everyone, who starts learning python, should get it. Excelent job. Keep up with a good work." - nicholas

Video Tutorials

1. Series Overview in 5 minutes

We look over what is covered in the series and what you'll learn in the following 1 hour 20 minutes of tutorial screencasts. Series Pre-requisite - note that you will need a working nosetest environment to complete all the episodes (necessary links are given), but you'll be able to work through the series without it (you'll just miss out a bit!). Links for getting the nosetest files are of cours [...]

2. Introducing .csv files and the Wing IDE

The aim of this series is to build a working tool which reads a .csv file, creates averages, writes a new .csv file and does so with some nice user-interface controls. To begin we need to know about .csv files (csv at wikipedia) and we need to test our choice of IDE - Wing IDE. We check that Wing's IDE works by writing a simple file and we execute both from inside Wing and from the DOS command l [...]

3. Batteries-included - the csv module

Python comes with its own comma-separated values (documentation) module - this is useful as there are many wrinkles with csv files that would make writing our own a pain (wikipedia: newline). Here you learn how to read in the contents of a csv file, one line at a time, as a list of strings. Task: Copy the csv example code and make the edits shown in the video Created May 2007, running time 6 minu [...]

4. Simple User Interfaces with easygui

easygui is a great module for building simple user-interfaces, created by Stephen Ferg, built on top of Tkinter. Here we learn how to create a file-open box in just 1 line of code, so we can easily open any .csv file. Tkinter is the cross-platform GUI module that is distributed with Python, but it has a learning-curve. easygui takes away the learning curve by providing a set of simple commands [...]

5. Debug Tip - Mising Import Statements

Do you know what happens if you mis-type an import statement? Learn about a common Python exception (and how to diagnose others) which will save you head-scratching time when you develop your own code. Find out about all the common Exceptions (exceptions doc page) including this ImportError in the Python doc pages. Created May 2007, running time 3 minutes.

6. Exercise: User Interaction with a Yes/No control and the EnterBox

Want to question the user with a dialog? Want to ask for text input? Learn how to do both in this episode, this is a digression from the main theme aimed at teaching you more about easygui's wide selection of user-interface controls. You'll learn about asking the user for input and also you'll have to think for a moment to write some Python logic. Created May 2007, running time 4 minutes

7. Solution: The working Yes/No control and EnterBox

Here we have the working solution to the exercise from the previous episode. See my answer for talking to the user and writing some more logic. Created May 2007, running time 2 minutes

8. Refactoring with functions and doc strings

Refactoring code is the sensible way to make your programs more manageable. You need documentation to help explain the purpose of the code and to remind you how it works in the future. Here we will refactor our program to add functions and documentation. Created May 2007, running time 7 minutes.

9. Starting with Unit-tests

Unit-tests are an invaluable development tool and should be a part of every developer's toolkit. Not only do they help us to test that our code works as expected, they also help us to write good code in the first place and point out errors that are introduced later in the development cycle. Here we test that the nosetests environment is installed and running before we go on to write tests for o [...]

10. Exception handling and Unit-testing with justNumbers

Now we write unit-tests for our code using the powerful Test-Driven Development (TDD) approach. Using TDD we expand the new justNumbers function which means we need to look at exception handling to sensibly handle a ValueError exception. In this episode you will learn about exception handling and you'll see why you should use the TDD approach to developing your own code. Created May 2007, runnin [...]

11. Completing getNumbers with Test Driven Development

We continue using the Test-Driven Development approach to write getNumbers and the associated test function. I give you the option of completing getNumbers yourself, ahead of my showing you how to write it, as an extra exercise for you. Created May 2007, running time 3 minutes

12. Error Handling to give user-feedback

User's need feedback when things don't go to plan. Learn how to develop code which gives useful error messages for the user and which exits gracefully (rather than crashing out with a horrible error). Our example is based around adding non-numeric data to the csv file which is caught by our justNumbers functions. We also look at rounding-errors with floating point numbers. Created May 2007, run [...]

13. Averaging the data

To calculate an average we need to introduce a new 'average' function - you'll need to write a test for it. To call the function we need to have our numerical data stored in a list, so we introduce 'measured1' and show how to populate the list. Task: Write the unit-test for the average function and replicate measured1 to create measured2 (both solved in the next episode) Created May 2007, runnin [...]

14. Solution to the unit-test task for average

Adding the unit-test for our average function takes just a few lines of code, here you can see my solution to the task that I set in the previous episode. We also look at the addition of the 'measured2' list and associated code which will calculate the average for the 2nd column of data. Created May 2007, running time 1 minute

15. easygui's choicebox for graphical list output

easygui has a nice component which lets us list items in a choicebox - this gives us a simple way of showing the contents of a list to the user. We can use this to output the 'measured1' list in graphical form. easygui has a number of other components so we use 'python' to run easygui's example program. This lets us see all of the components, making it easy to figure out the full ran [...]

16. Writing the new .csv file with an average

Now we're in a position to write out a new .csv file (using the csv module) which can be read by Excel. We start with a simple .csv file which looks identical to the one we read in, then we add the new row for the averaged values. We go on to use Excel's '=average' functions to verify that we have indeed calculated the right output. Created May 2007, running time 7 minutes

17. Presenting the finished product

Here we present the finished article. First we use argInitialFile = '*.csv' in the fileopenbox (and filesavebox) to filter just the .csv files. We also remove the 'print' statements that we used during development and end up with the finished tool. For further research you may want to investigate the Numpy numerical-python module, Python's built-in math module, matplotlib for great plotting and [...]

Showmedo is a peer-produced video-tutorials and screencasts site for free and open-source software (FOSS)- with the exception of some club videos, the large majority are free to watch and download.

how to help » about » faq »

Educating the Open-source Community With Showmedo

Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world. Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined.

At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration.

Screencasting is easier than you think, and we're happy to help you. You can emailus for advice or just use some of the how-to screencasts on the site. This screencasting learning-pathis a good place to start.

Kudos and Thanks for Ian

3 Minute Oveview (What Does Python Look Like?)

simple and informative. you draw me in
70 months ago

Learning Paths

This series lies on the following learning-paths. Learning-paths are a new initiative at Showmedo, to start structuring our content better. You can find out more here.



Showmedo's development is fairly rapid and bugs will inevitably creep in. If you have any problems please drop us a line using the contact address below. Likewise, any suggestions for improvements to the site are gratefully received.