]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151556: Show example CSV file content in the `csv` module docs (#151563)
authorLucas <lucasefernandes333@gmail.com>
Tue, 23 Jun 2026 12:01:21 +0000 (09:01 -0300)
committerGitHub <noreply@github.com>
Tue, 23 Jun 2026 12:01:21 +0000 (13:01 +0100)
Co-authored-by: Stan Ulbrych <stan@python.org>
Doc/library/csv.rst

index 21ecdbcc08f3486669474a235d2f1dc73f8ab8f4..87c2d4702e74086d3ee4327028311488f2a0aabe 100644 (file)
@@ -81,6 +81,13 @@ The :mod:`!csv` module defines the following functions:
       Spam, Spam, Spam, Spam, Spam, Baked Beans
       Spam, Lovely Spam, Wonderful Spam
 
+   where :file:`eggs.csv` contains:
+
+   .. code-block:: text
+
+      Spam Spam Spam Spam Spam |Baked Beans|
+      Spam |Lovely Spam| |Wonderful Spam|
+
 
 .. function:: writer(csvfile, /, dialect='excel', **fmtparams)
 
@@ -110,6 +117,13 @@ The :mod:`!csv` module defines the following functions:
           spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])
           spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
 
+   which writes :file:`eggs.csv` containing:
+
+   .. code-block:: text
+
+      Spam Spam Spam Spam Spam |Baked Beans|
+      Spam |Lovely Spam| |Wonderful Spam|
+
 
 .. function:: register_dialect(name, /, dialect='excel', **fmtparams)
 
@@ -191,6 +205,14 @@ The :mod:`!csv` module defines the following classes:
        >>> print(row)
        {'first_name': 'John', 'last_name': 'Cleese'}
 
+   where :file:`names.csv` contains:
+
+   .. code-block:: text
+
+      first_name,last_name
+      Eric,Idle
+      John,Cleese
+
 
 .. class:: DictWriter(f, fieldnames, restval='', extrasaction='raise', \
                       dialect='excel', *args, **kwds)
@@ -228,6 +250,15 @@ The :mod:`!csv` module defines the following classes:
            writer.writerow({'first_name': 'Lovely', 'last_name': 'Spam'})
            writer.writerow({'first_name': 'Wonderful', 'last_name': 'Spam'})
 
+   which writes :file:`names.csv` containing:
+
+   .. code-block:: text
+
+      first_name,last_name
+      Baked,Beans
+      Lovely,Spam
+      Wonderful,Spam
+
 
 .. class:: Dialect