New submission from ivanoe <[EMAIL PROTECTED]>: 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. ---------- assignee: georg.brandl components: Documentation, Library (Lib) messages: 64160 nosy: georg.brandl, ivanoe severity: normal status: open title: DictReader does not suport line_num type: behavior versions: Python 2.5 __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2432> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com