Skip to content

csvwriter.writerow()'s return type is undocumented #78894

Closed

Description

@nchammas
mannequin
BPO 34713
Nosy @nchammas, @remilapeyre, @tirkarthi

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2018-09-17.17:14:05.366>
labels = ['3.7', '3.8', 'type-feature', 'library', 'docs']
title = "csvwriter.writerow()'s return type is undocumented"
updated_at = <Date 2019-03-13.17:09:31.263>
user = 'https://github.com/nchammas'

bugs.python.org fields:

activity = <Date 2019-03-13.17:09:31.263>
actor = 'nchammas'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation', 'Library (Lib)']
creation = <Date 2018-09-17.17:14:05.366>
creator = 'nchammas'
dependencies = []
files = []
hgrepos = []
issue_num = 34713
keywords = []
message_count = 5.0
messages = ['325557', '325559', '337776', '337840', '337866']
nosy_count = 4.0
nosy_names = ['docs@python', 'nchammas', 'remi.lapeyre', 'xtreak']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue34713'
versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

Activity

  1. nchammas commented on Sep 17, 2018

    nchammasmannequin
    MannequinAuthor

    It _looks_ like csvwriter.writerow() returns the number of bytes (or is it characters?) written. However, there is no documentation of this:

    https://docs.python.org/3.7/library/csv.html#csv.csvwriter.writerow

    Is this behavior part of the method's "contract"? And if so, shouldn't we document it?

    The same goes for csvwriter.writerows().

  2. added
    docsDocumentation in the Doc dir
    stdlibStandard Library Python modules in the Lib/ directory
    type-featureA feature request or enhancement
    on Sep 17, 2018
  3. nchammas commented on Sep 17, 2018

    nchammasmannequin
    MannequinAuthor

    Looks like it's bytes written, not characters:

    >>> import csv
    >>> with open('test.csv', 'w', newline='') as csv_file:
    ...     csv_writer = csv.writer(
    ...         csv_file,
    ...         dialect='unix',
    ...     )
    ...     csv_writer.writerow('야 너')  # 3 characters
    ... 
    12
    
  4. remilapeyre commented on Mar 12, 2019

    remilapeyremannequin
    Mannequin

    csvwriter.writerows() does not return anything.

    The return value of csv.writecsv() is the return value of the write() method of the file object given as parameter in csv.writer(). I'm not sure it's safe to document it, should we return None instead?

  5. remilapeyre commented on Mar 13, 2019

    remilapeyremannequin
    Mannequin

    Issue bpo-27497 is related, it adds documentation a return value and documentation to csv.DictWriter.writeheader which uses writerow internally.

    In the discussion, @lsowen found code that uses it at https://docs.djangoproject.com/en/1.9/howto/outputting-csv/#streaming-large-csv-files.

    Given that this behavior has been added to csv.DictWriter.writeheader it makes sense to document csv.Writer.writerow. Do you want to post a pull request?

  6. nchammas commented on Mar 13, 2019

    nchammasmannequin
    MannequinAuthor

    Nope, go ahead.

  7. transferred this issue fromon Apr 10, 2022
  8. slateny commented on May 5, 2022

    @slateny
    Contributor

    Resolved by #12306

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.7 (EOL)end of life3.8 (EOL)end of lifedocsDocumentation in the Doc dirstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions