This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008年03月20日 08:46 by ivanoe, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (2) | |||
|---|---|---|---|
| msg64160 - (view) | Author: (ivanoe) | Date: 2008年03月20日 08:46 | |
Documentation http://docs.python.org/lib/node264.html mentions that both 'reader' and 'DictReader' support 'line_num' fields. But in fact in version 2.5.2 of the library line_num is not in 'DictReader' class. (looking at csv.py) For the moment I created little wrapper class to handle the issue, but it should be done in the original 'DictReader' to support uniform 'interface' of the reader. {{{ import csv class DictReader(csv.DictReader): """ DictReader that supports line_num field. """ def __init__(self, f, fieldnames=None, restkey=None, restval=None, dialect="excel", *args, **kwds): csv.DictReader.__init__(self, f, fieldnames, restkey, restval, dialect) self.line_num = 0 def next(self): res = csv.DictReader.next(self) self.line_num+=1 return res }}} (sorry, no tests) I suggest that line_num gets implemented, rather then documentation changed. |
|||
| msg64268 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年03月21日 20:02 | |
Fixed by adding line_num attr to DictReader in r61712, r61713 (2.5). |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:32 | admin | set | github: 46684 |
| 2008年03月21日 20:02:08 | georg.brandl | set | status: open -> closed resolution: fixed messages: + msg64268 |
| 2008年03月20日 08:46:59 | ivanoe | create | |