From skip at pobox.com  Sun Mar  8 20:20:44 2009
From: skip at pobox.com (skip at pobox.com)
Date: Sun,  8 Mar 2009 14:20:44 -0500 (CDT)
Subject: [Csv] Named tuple reader proposal for CSV module
Message-ID: <20090308192044.6879EE46498@montanaro.dyndns.org>

Subscribers to this list might want to acquaint themselves with this
currently active issue in the Python tracker:

    http://bugs.python.org/issue1818

It's a proposal to add a named tuple reader to the csv module.

Skip

From jervisau at gmail.com  Mon Mar  9 00:00:36 2009
From: jervisau at gmail.com (Jervis Whitley)
Date: Mon, 9 Mar 2009 10:00:36 +1100
Subject: [Csv] Removal of csv doc about .next()
Message-ID: <8e63a5ce0903081600q3ede21a1w594823581b613e6f@mail.gmail.com>

-Reader objects (:class:`DictReader` instances and objects returned by the
-:func:`reader` function) have the following public methods:
-
-
-.. method:: csvreader.next()
-
-   Return the next row of the reader's iterable object as a list,
parsed according
-   to the current dialect.

csvreader no longer has this public method (py3k). Can we remove this
from the docs
and replace with a suitable substitute (information about using
next(csvreader) )?

Cheers,

Jervis

From skip at pobox.com  Mon Mar  9 03:37:03 2009
From: skip at pobox.com (skip at pobox.com)
Date: Sun, 8 Mar 2009 21:37:03 -0500
Subject: [Csv] Removal of csv doc about .next()
In-Reply-To: <8e63a5ce0903081600q3ede21a1w594823581b613e6f@mail.gmail.com>
References: <8e63a5ce0903081600q3ede21a1w594823581b613e6f@mail.gmail.com>
Message-ID: <18868.32975.341219.81502@montanaro.dyndns.org>


    Jervis> -.. method:: csvreader.next()
    Jervis> -
    Jervis> -   Return the next row of the reader's iterable object as a list,
    Jervis> parsed according
    Jervis> -   to the current dialect.

    Jervis> csvreader no longer has this public method (py3k). Can we remove
    Jervis> this from the docs and replace with a suitable substitute
    Jervis> (information about using next(csvreader) )?

This is the first I've heard about it (well, except for the point being
raised by a comment of yours in issue 1818 on bugs.python.org).  Is it
because Python 3.x has a next() builtin?

Crap...  This completely snuck by me:

    >>> csv.reader(open("f.csv", "rb")).next()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: '_csv.reader' object has no attribute 'next'
    >>> dir(csv.reader(open("f.csv", "rb")))
    ['__class__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__lt__', '__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'dialect', 'line_num']
    >>> next(csv.reader(open("f.csv", "rb")))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    _csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)
    >>> next(csv.reader(open("f.csv", "r")))
    ['col1', 'col2', 'color']

This demonstrates a larger bug in the 3.x version of the csv module.  You
can no longer open CSV files in binary mode, yet that is precisely what the
documentation has always said:

    If csvfile is a file object, it must be opened with the �$,1rxb�$,1ry flag on
    platforms where that makes a difference.

Opening a file in binary mode now returns bytes.  Something's got to give.

Skip

From skip at pobox.com  Mon Mar  9 03:49:48 2009
From: skip at pobox.com (skip at pobox.com)
Date: Sun,  8 Mar 2009 21:49:48 -0500 (CDT)
Subject: [Csv] New csv binary mode issue
Message-ID: <20090309024948.4750FE48387@montanaro.dyndns.org>

I just opened a new issue about the binary mode problem with next():

    http://bugs.python.org/issue5455

Skip

From sjmachin at lexicon.net  Mon Mar  9 05:34:29 2009
From: sjmachin at lexicon.net (John Machin)
Date: Mon, 09 Mar 2009 15:34:29 +1100
Subject: [Csv] New csv binary mode issue
In-Reply-To: <20090309024948.4750FE48387@montanaro.dyndns.org>
References: <20090309024948.4750FE48387@montanaro.dyndns.org>
Message-ID: <49B49C55.9070808@lexicon.net>

On 9/03/2009 1:49 PM, skip at pobox.com wrote:
> I just opened a new issue about the binary mode problem with next():
> 
>     http://bugs.python.org/issue5455
> 
> Skip


Hi Skip,

There is a more general issue: it's not just next(); 3.0 just fails 
anyhow when the file has been opened with 'rb' mode.

*AND* the issue has already been raised; see 
http://bugs.python.org/issue4847

I only stumbled across this on c.l.py ... IIRC somebody was opining that 
it was just a documentation bug. Is there any way that someone can 
register with the tracker so that if a new bug report is opened on a 
topic they are interested in, they get notified, or added to the "nosy" 
list? You know, just like favourite searches on eBay :-)

Cheers,
John

From skip at pobox.com  Mon Mar  9 14:20:01 2009
From: skip at pobox.com (skip at pobox.com)
Date: Mon, 9 Mar 2009 08:20:01 -0500
Subject: [Csv] New csv binary mode issue
In-Reply-To: <49B49C55.9070808@lexicon.net>
References: <20090309024948.4750FE48387@montanaro.dyndns.org>
	<49B49C55.9070808@lexicon.net>
Message-ID: <18869.6017.575246.656041@montanaro.dyndns.org>


    >> http://bugs.python.org/issue5455

    John> There is a more general issue: it's not just next(); 3.0 just fails 
    John> anyhow when the file has been opened with 'rb' mode.

    John> *AND* the issue has already been raised; see 
    John> http://bugs.python.org/issue4847

    John> I only stumbled across this on c.l.py ... IIRC somebody was
    John> opining that it was just a documentation bug. Is there any way
    John> that someone can register with the tracker so that if a new bug
    John> report is opened on a topic they are interested in, they get
    John> notified, or added to the "nosy" list? You know, just like
    John> favourite searches on eBay :-)

I'm not sure how to proceed.  I will raise the topic on python-dev.  That's
populated with folks who have already crossed the bytes/unicode bridge in
other parts of Python 3.  It would be real nice to get this fixed before 3.1
is released.

As for auto-nosy, I don't know.  You might try sending a note to
tracker-discuss at python.org.  Daniel Diniz or Martin v. Loewis will probably
know.

Skip