diff options
author | R. David Murray <rdmurray@bitdance.com> | 2010-02-23 22:57:58 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2010-02-23 22:57:58 (GMT) |
commit | be0698b1ad096d8bd6564fa06486f2fcea47cac9 (patch) | |
tree | 892dc44548a60c7a3d457b8f44e9cd4cd35024b3 /Lib/csv.py | |
parent | 5117b0b0dc9c28d158c9f46bca0965ee00ac98e7 (diff) | |
download | cpython-be0698b1ad096d8bd6564fa06486f2fcea47cac9.zip cpython-be0698b1ad096d8bd6564fa06486f2fcea47cac9.tar.gz cpython-be0698b1ad096d8bd6564fa06486f2fcea47cac9.tar.bz2 |
Merged revisions 78384 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78384 | dirkjan.ochtman | 2010-02-23 16:09:52 -0500 (Tue, 23 Feb 2010) | 4 lines
Fix #1537721: add writeheader() method to csv.DictWriter.
Reviewed by skip.montanaro and thomas.wouters.
........
Diffstat (limited to 'Lib/csv.py')
-rw-r--r-- | Lib/csv.py | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -127,6 +127,10 @@ class DictWriter: self.extrasaction = extrasaction self.writer = writer(f, dialect, *args, **kwds) + def writeheader(self): + header = dict(zip(self.fieldnames, self.fieldnames)) + self.writerow(header) + def _dict_to_list(self, rowdict): if self.extrasaction == "raise": wrong_fields = [k for k in rowdict if k not in self.fieldnames] |