Name:
[002] Ian Ozsvald
Member:
90 months
Authored:
181 videos
Description:
I am the co-founder of ShowMeDo (see http://showmedo.com/about), author of `The Screencasting Handbook <http://thescreencastinghandbook.com>`_ and the founder of the professional screencast production company `ProCasts <http://procasts.co.uk>`_:
.. image:: http://procasts.co.uk/media/procasts_sma ...
Batteries-included - the csv module [ID:244] (3/17)
in series: Python 101 - easygui and csv
video tutorial by Ian Ozsvald, added 05/07
Name:
[002] Ian Ozsvald
Member:
90 months
Authored:
181 videos
Description:
I am the co-founder of ShowMeDo (see http://showmedo.com/about), author of `The Screencasting Handbook <http://thescreencastinghandbook.com>`_ and the founder of the professional screencast production ...
Our authors tell us that feedback from you is a big motivator. Please take a few moments to let them know what you think of their work.
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 minutes.
- python
- beginners
- tutorials
- beginner_programming
- code
- time
- running
- graphics
- application
- files
- make
- screencasts
- learn
- development
- user
- work
- builds
- IDE
- useful
- learning
- modules
- programmers
- writing
- lists
- good
- read
- interfaces
- values
- problem
- wing
- debugging
- nosetests
- messages
- easygui
- wingware
- complete
- fully-worked
- keep
- tasks
- csv
- reviews
- understanding
- copy
- jobs
- exceptions
- strings
- refactoring
- test-driven
- comma-separated-values
Got any questions?
Get answers in the ShowMeDo Learners Google Group.
Video statistics:
- Video's rank shown in the most popular listing
- Video plays: 827 (since July 30th)
- Plays in last week: 0
- Published: 72 months ago
Thank-yous, questions and comments
If this video tutorial was helpful please take some time to say thank-you to the authors for their hard work. Feel free to ask questions. Let the author know why their video tutorial was useful - what are you learning about? Did the video tutorial save you time? Would you like to see more?
You may also want to see our ShowMeDo Google Group to speak to our active users and authors.
All comments excluding tick-boxed quick-comments
a very good start ...
Im gay...
very good one, indeed.
Very good and thorough. Looking forward to completing the series!
Thanks for this. I like the pace at which this is explained and how every step is shown...much better then just a book tutorial.
Batteries-included - the csv module (3/17)
1:20 Read binary for CSV for cross platform
1:52 Wikipedia newline
3:00 import csv
3:20 csv.reader(open
3:40 for row in reader
4:19 output explained [lists of strings]
5:09 Run in DOS
Resources:
I am following along, but trying ti substitute vi tools in place of WingIDE. What I found I like is:
gvim + pdb + vimpdb plugin for debugger.
Also, this script in your .vimrc will let you run the currently open file though the python interpreter and diaply the output in the preview window.
http://strongdynamic.blogspot.com/2007/10/vim-run-current-buffer-as-python-code.html
Great tut
Hi Ian,
Ihave done a lot of importing and exporting csv files in and out of Excel, usually using AWK and regular expressions. The Python csv module makes life so much easier, especially compared to cutting and pasting in Excel. A great tool to have in your toolkit.
Excellent screencast!
Jerol
Will running the free version of Wing IDE get me through the series? Thanks!
Just as a Kevin reported, I'm reading from a csv file and I'm getting the "line contains NULL byte".
<<
Runtime Error!
line contains NULL byte
Rolling back...
Exiting
>>
Not sure whatelse to include here, but was trying to get an idea on this "line contains NULL byte" error and if anybody else has had the same issue.
Any help is much appreciated!
All good Ian. I'm with you so far. Onward to the next tutorial.
Hi, I am getting the code to run in the wing IDE environment. However when I try to run the program in DOS I get this error "python: can't open file 'csvReader.py' : [Errno 2] No such file or directory."
I created the .csv file in the text editor, saved it in the directory where my .py program lives and cannot run it. Can you offer some help.
Thanks,
Jason
I liked the video and it was great to make something that seems like a real program so early on. However the set up of Easygui could have been explained better as I ended spending up a lot more time figuring that out than learning the language itself. As such, the code in the video does not run in my environment.
Very, very helpful.
Thanks
Brand new to python and could not get command line to run until I had run "set path=%path%;C:\python25" at the command line. Took a while to track down so I thought I would mention it here.
Hi Kevin - I'm mailing you privately to help you out.
Ian.
i am new to python and found this great video class while I was googling.
I ran into problems with The CSV class - video 2,
I follow the Video trying to run the csvReader.py, the following result shown when I use DOS command lineas well as with IDLE (I do not have Wing IDE), please help in so I go move on :
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "C:\Python25\python-training\OnLineTraining\Class1\csvReader.py", line 3, in <module>
for row in reader:
Error: line contains NULL byte
I was ahead of myself again, by actually listening to the video, I figured it out :)
I must be blind again is there code and a ,csv to download here on this page (I found the examples in the csv doco)
Great tuto, I was just not getting the right output initialy reason being my regional setting were at "french canadian" so I had the comma-period problem, I did switch to "english canadian" and the problem was resolved.
Thanks. That's perfect.
Hi Ryan. The type of an object tells you 'what it is' behind the scenes. Your 'reader' is a part of the 'csv' module.
The reason it says _csv rather than csv is rather technical - the _csv file is a pre-compiled Python module which is used by the public-facing csv module.
On my machine I see csv.py in /usr/lib/python2.5 and _csv.so lives in /usr/lib/python2.5/lib-dynload.
I guess a shorter answer is that the 'type' is the way that Python describes this kind of object, a bit like saying 'book.technical_reference' or 'food.pasta'.
There's an introduction to basic Python types (but not csv) here:
http://www.ibm.com/developerworks/opensource/library/os-python2/
which might give you some more background?
Ian.
You are an excellent instructor Ian. I have a quick question, when I type the following code in the shell I get this:
>>> type(reader)
<type '_csv.reader'>
What is this specifc type supposed to mean?
Hi ttjfb - the csv module is *built in* to Python, there is nothing extra to install. I will mail you privately so we can check your configuration and sort this out...
Ian.
Is there a step by step anywhere of installing the CSV module, even though the WINGIDE is 2.3 etc.. it tells me it can't find CSV module?
Fair enough. I gave the example needed for this series but yes, more examples always help, maybe that's something to bear in mind for future series.
Cheers,
Ian.
I liked the introduction to the CSV module, but I think it might have been a bit better with a few more examples of what the CSV module can do.
very cool video, i learned new things.
