[Tutor] Adding to a CSV file?
rabidpoobear at gmail.com
Mon Aug 30 19:44:07 CEST 2010
On Mon, Aug 30, 2010 at 12:04 PM, <aeneas24 at priest.com> wrote:
> I checked out the csv module and got a little further along, but still can't
> quite figure out how to iterate line by line properly.
> > # But when I try to add columns, I'm only filling in some static value. So
> there's something wrong with my looping.
> testReader=csv.reader(open('test-8-29-10.csv', 'rb'))
> for line in testReader:
> for MyWord, Category, Ct, CatCt in testReader:
here's your problem. MyWord is the value that is changing in each
iteration of the loop, not word.
Change your lines to
and it should work fine.
You should've gotten an undefined variable exception, unless you
defined word somewhere else.
Watch those variable names!
More information about the Tutor