From cd29cbc19b98a503aa06286cdc156440fabeda45 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 3 May 2024 10:05:38 -0400 Subject: [PATCH 1/2] docs: clarify DictReader's treatment of the first data row. --- Doc/library/csv.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index 4ee7820585d3a2..8427c2599910be 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -156,8 +156,10 @@ The :mod:`csv` module defines the following classes: 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 - dictionary preserves their original ordering. + fieldnames and the first row will not produce a dict in the result. If + *fieldnames* is provided, they will be used and the first row will be + included in the result. 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 list and stored with the fieldname specified by *restkey* (which defaults From a52cba161b41aac8bf1a5b7ab7e43b02573660d6 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 3 May 2024 10:20:38 -0400 Subject: [PATCH 2/2] docs: (to squash) tighter wording --- Doc/library/csv.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index 8427c2599910be..d17468023c6de1 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -156,9 +156,9 @@ The :mod:`csv` module defines the following classes: 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 and the first row will not produce a dict in the result. If + fieldnames and will be omitted from the results. If *fieldnames* is provided, they will be used and the first row will be - included in the result. Regardless of how the fieldnames are determined, + included in the results. 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