[Csv] Problems with CSV Module

Andrew McNamara andrewm at object-craft.com.au
Mon Jun 23 03:58:00 CEST 2003


>I think most of what Andreas asked about has either been taken care of or
>shown not to be useful, however there is this request outstanding:
>
>    Andreas> 4. There is no .readrow()
>    Andreas> This should be just another name for .next(). It's more
>    Andreas> intuitive if you write a row via .writerow() and read it via
>    Andreas> .readrow().
>
>What do people think?  It should be an easy addition for Dave or Andrew, but
>I'm not sure it's really needed.  If readrow() is really a synonym for
>next() I suppose it should also raise StopIteration upon completion, but
>that seems odd.  Is there another reasonable way to signal completion
>without raising an exception (say, by returning None or some other
>non-sequence value)?

The use of iterators for reading rows is quite natural, but there is
no equivalent concept for writing, hence the writerow method. I agree
that the lack of symmetry is a bit of a wart, but the proposed solution
doesn't feel any better to me.

I agree that readrow() couldn't simply be a synonym for the .next()
method, although the iterator protocol is simple enough that we could
wrap Reader_iternext to produce a readrow method. 

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/


More information about the Csv mailing list