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.
| Author | ivanoe |
|---|---|
| Recipients | georg.brandl, ivanoe |
| Date | 2008年03月20日.08:46:57 |
| SpamBayes Score | 0.4323346 |
| Marked as misclassified | No |
| Message-id | <1206002820.55.0.716931876955.issue2432@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
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. |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2008年03月20日 08:47:01 | ivanoe | set | spambayes_score: 0.432335 -> 0.4323346 recipients: + ivanoe, georg.brandl |
| 2008年03月20日 08:47:00 | ivanoe | set | spambayes_score: 0.432335 -> 0.432335 messageid: <1206002820.55.0.716931876955.issue2432@psf.upfronthosting.co.za> |
| 2008年03月20日 08:46:59 | ivanoe | link | issue2432 messages |
| 2008年03月20日 08:46:57 | ivanoe | create | |