@@ -94,8 +94,8 @@ The :mod:`csv` module defines the following functions:
94
94
:class: `Dialect ` class or one of the strings returned by the
95
95
:func: `list_dialects ` function. The other optional *fmtparams * keyword arguments
96
96
can be given to override individual formatting parameters in the current
97
- dialect. For full details about the dialect and formatting parameters, see
98
- section :ref: `csv-fmt-params `. To make it
97
+ dialect. For full details about dialects and formatting parameters, see
98
+ the :ref: `csv-fmt-params ` section . To make it
99
99
as easy as possible to interface with modules which implement the DB API, the
100
100
value :const: `None ` is written as the empty string. While this isn't a
101
101
reversible transformation, it makes it easier to dump SQL NULL data values to
@@ -117,7 +117,7 @@ The :mod:`csv` module defines the following functions:
117
117
Associate *dialect * with *name *. *name * must be a string. The
118
118
dialect can be specified either by passing a sub-class of :class: `Dialect `, or
119
119
by *fmtparams * keyword arguments, or both, with keyword arguments overriding
120
- parameters of the dialect. For full details about the dialect and formatting
120
+ parameters of the dialect. For full details about dialects and formatting
121
121
parameters, see section :ref: `csv-fmt-params `.
122
122
123
123
@@ -225,9 +225,21 @@ The :mod:`csv` module defines the following classes:
225
225
226
226
.. class :: Dialect
227
227
228
- The :class: `Dialect ` class is a container class relied on primarily for its
229
- attributes, which are used to define the parameters for a specific
230
- :class: `reader ` or :class: `writer ` instance.
228
+ The :class: `Dialect ` class is a container class whose attributes contain
229
+ information for how to handle doublequotes, whitespace, delimiters, etc.
230
+ Due to the lack of a strict CSV specification, different applications
231
+ produce subtly different CSV data. :class: `Dialect ` instances define how
232
+ :class: `reader ` and :class: `writer ` instances behave.
233
+
234
+ All available :class: `Dialect ` names are returned by :func: `list_dialects `,
235
+ and they can be registered with specific :class: `reader ` and :class: `writer `
236
+ classes through their initializer (``__init__ ``) functions like this::
237
+
238
+ import csv
239
+
240
+ with open('students.csv', 'w', newline='') as csvfile:
241
+ writer = csv.writer(csvfile, dialect='unix')
242
+ ^^^^^^^^^^^^^^
231
243
232
244
233
245
.. class :: excel()
@@ -419,8 +431,8 @@ Reader objects (:class:`DictReader` instances and objects returned by the
419
431
420
432
Return the next row of the reader's iterable object as a list (if the object
421
433
was returned from :func: `reader `) or a dict (if it is a :class: `DictReader `
422
- instance), parsed according to the current dialect . Usually you should call
423
- this as ``next(reader) ``.
434
+ instance), parsed according to the current :class: ` Dialect ` . Usually you
435
+ should call this as ``next(reader) ``.
424
436
425
437
426
438
Reader objects have the following public attributes:
@@ -460,9 +472,9 @@ read CSV files (assuming they support complex numbers at all).
460
472
461
473
.. method :: csvwriter.writerow(row)
462
474
463
- Write the *row * parameter to the writer's file object, formatted according to
464
- the current dialect . Return the return value of the call to the * write * method
465
- of the underlying file object.
475
+ Write the *row * parameter to the writer's file object, formatted according
476
+ to the current :class: ` Dialect ` . Return the return value of the call to the
477
+ * write * method of the underlying file object.
466
478
467
479
.. versionchanged :: 3.5
468
480
Added support of arbitrary iterables.
0 commit comments