dialect='excel', *args, **kwds)
Create an object that operates like a regular reader but maps the
- information in each row to an :mod:`OrderedDict <collections.OrderedDict>`
- whose keys are given by the optional *fieldnames* parameter.
+ information in each row to a :class:`dict` whose keys are given by the
+ optional *fieldnames* parameter.
The *fieldnames* parameter is a :term:`sequence`. If *fieldnames* is
omitted, the values in the first row of file *f* will be used as the
- fieldnames. Regardless of how the fieldnames are determined, the ordered
+ fieldnames. Regardless of how the fieldnames are determined, the
dictionary preserves their original ordering.
If a row has more fields than fieldnames, the remaining data is put in a
All other optional or keyword arguments are passed to the underlying
:class:`reader` instance.
- .. versionchanged:: 3.6
- Returned rows are now of type :class:`OrderedDict`.
+ .. versionchanged:: 3.8
+ Returned rows are now of type :class:`dict`.
A short usage example::
John Cleese
>>> print(row)
- OrderedDict([('first_name', 'John'), ('last_name', 'Cleese')])
+ {'first_name': 'John', 'last_name': 'Cleese'}
.. class:: DictWriter(f, fieldnames, restval='', extrasaction='raise', \
__doc__
from _csv import Dialect as _Dialect
-from collections import OrderedDict
from io import StringIO
__all__ = ["QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE",
# values
while row == []:
row = next(self.reader)
- d = OrderedDict(zip(self.fieldnames, row))
+ d = dict(zip(self.fieldnames, row))
lf = len(self.fieldnames)
lr = len(row)
if lf < lr: