| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -150,12 +150,12 @@ The :mod:`csv` module defines the following classes: | |||
| 150 | 150 | dialect='excel', *args, **kwds) | |
| 151 | 151 | ||
| 152 | 152 | Create an object that operates like a regular reader but maps the | |
| 153 | - information in each row to an :mod:`OrderedDict <collections.OrderedDict>` | ||
| 154 | - whose keys are given by the optional *fieldnames* parameter. | ||
| 153 | + information in each row to a :class:`dict` whose keys are given by the | ||
| 154 | + optional *fieldnames* parameter. | ||
| 155 | 155 | ||
| 156 | 156 | The *fieldnames* parameter is a :term:`sequence`. If *fieldnames* is | |
| 157 | 157 | omitted, the values in the first row of file *f* will be used as the | |
| 158 | - fieldnames. Regardless of how the fieldnames are determined, the ordered | ||
| 158 | + fieldnames. Regardless of how the fieldnames are determined, the | ||
| 159 | 159 | dictionary preserves their original ordering. | |
| 160 | 160 | ||
| 161 | 161 | If a row has more fields than fieldnames, the remaining data is put in a | |
@@ -166,8 +166,8 @@ The :mod:`csv` module defines the following classes: | |||
| 166 | 166 | All other optional or keyword arguments are passed to the underlying | |
| 167 | 167 | :class:`reader` instance. | |
| 168 | 168 | ||
| 169 | - .. versionchanged:: 3.6 | ||
| 170 | - Returned rows are now of type :class:`OrderedDict`. | ||
| 169 | + .. versionchanged:: 3.8 | ||
| 170 | + Returned rows are now of type :class:`dict`. | ||
| 171 | 171 | ||
| 172 | 172 | A short usage example:: | |
| 173 | 173 | ||
@@ -181,7 +181,7 @@ The :mod:`csv` module defines the following classes: | |||
| 181 | 181 | John Cleese | |
| 182 | 182 | ||
| 183 | 183 | >>> print(row) | |
| 184 | - OrderedDict([('first_name', 'John'), ('last_name', 'Cleese')]) | ||
| 184 | + {'first_name': 'John', 'last_name': 'Cleese'} | ||
| 185 | 185 | ||
| 186 | 186 | ||
| 187 | 187 | .. class:: DictWriter(f, fieldnames, restval='', extrasaction='raise', \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,6 @@ | |||
| 11 | 11 | __doc__ | |
| 12 | 12 | from _csv import Dialect as _Dialect | |
| 13 | 13 | ||
| 14 | - from collections import OrderedDict | ||
| 15 | 14 | from io import StringIO | |
| 16 | 15 | ||
| 17 | 16 | __all__ = ["QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE", | |
@@ -117,7 +116,7 @@ def __next__(self): | |||
| 117 | 116 | # values | |
| 118 | 117 | while row == []: | |
| 119 | 118 | row = next(self.reader) | |
| 120 | - d = OrderedDict(zip(self.fieldnames, row)) | ||
| 119 | + d = dict(zip(self.fieldnames, row)) | ||
| 121 | 120 | lf = len(self.fieldnames) | |
| 122 | 121 | lr = len(row) | |
| 123 | 122 | if lf < lr: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + csv.DictReader now creates dicts instead of OrderedDicts. Patch by Michael | ||
| 2 | + Selik. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments