Skip to content

Conversation

@aktech
Copy link
Contributor

@aktech aktech commented Feb 18, 2017

csv.reader

>>> import csv
>>> fp = open('foo.csv')
>>> csv_reader = csv.reader(fp)
>>> next(csv_reader)
['a', 'b', 'c', 'd']

csv.DictReader

>>> fp = open('foo.csv')
>>> csv_dict_reader = csv.DictReader(fp)
>>> next(csv_dict_reader)
OrderedDict([('a', 'e'), ('b', 'f'), ('c', 'g'), ('d', 'h')])

Contents of foo.csv

a,b,c,d
e,f,g,h
i,j,k,l

Documentation: https://docs.python.org/3.7/library/csv.html#reader-objects

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow these steps to rectify the issue:

  1. Sign the PSF contributor agreement
  2. Wait at least one US business day and then check "Your Details" on bugs.python.org to see if your account has been marked as having signed the CLA (the delay is due to a person having to manually check your signed CLA)
  3. Reply here saying you have completed the above steps

Thanks again to your contribution and we look forward to looking at it!

to the current dialect. Usually you should call this as ``next(reader)``.
Return the next row of the reader's iterable object as a list (if reader) or
dict (if DictReader), parsed according to the current dialect. Usually you
should call this as ``next(reader)``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to change these to:

Return the next row of the reader's iterable object as a list (if the object was returned from reader()) or a dict (if it is a DictReader) [...]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! Fixed.

@JDLH
Copy link
Contributor

JDLH commented Feb 20, 2017

Could you please check the bpo number? bpo-29521 has to do with Sphinx and building documentation, and has nothing to do with CSV support. As far as I know.

@aktech aktech changed the title bpo-29521 document return type of next method of csv reader bpo-21056 document return type of next method of csv reader Feb 20, 2017
@aktech
Copy link
Contributor Author

aktech commented Feb 20, 2017

Could you please check the bpo number? bpo-29521 has to do with Sphinx and building documentation, and has nothing to do with CSV support. As far as I know.

Yeah, Thanks! I have fixed it now.

Return the next row of the reader's iterable object as a list, parsed according
to the current dialect. Usually you should call this as ``next(reader)``.
Return the next row of the reader's iterable object as a list (if the object
was returned from ``reader()``) or a dict (if it is a ``DictReader``), parsed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reader() is not very clear here. "[...] from :func:`reader`" would be much clearer.

Return the next row of the reader's iterable object as a list, parsed according
to the current dialect. Usually you should call this as ``next(reader)``.
Return the next row of the reader's iterable object as a list (if the object
was returned from ``reader()``) or a dict (if it is a ``DictReader``), parsed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is a :class:`DictReader` instance

to the current dialect. Usually you should call this as ``next(reader)``.
Return the next row of the reader's iterable object as a list (if the object
was returned from ``reader()``) or a dict (if it is a ``DictReader``), parsed
according to the current dialect. Usually you should call this as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add two spaces after a full-stop:

[...] dialect.  Usually [...]

@berkerpeksag berkerpeksag changed the title bpo-21056 document return type of next method of csv reader bpo-21056: Document return type of next method of csv reader Feb 21, 2017
@aktech
Copy link
Contributor Author

aktech commented Feb 21, 2017

@berkerpeksag Thanks for the Review, I have made the changes now. Please have a look.

Copy link
Member

@berkerpeksag berkerpeksag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this again, I agree with Josh Rosenberg's comment at https://bugs.python.org/issue21056#msg214856 It would be better to the documentation for __next__ and document the return types of them in their documentation. Plus, we can adapt the examples you gave in #146 (comment) to the existing ones.

@rhettinger
Copy link
Contributor

This looks fine. I'm not sure it is necessary though (I don't recall it ever having been a source of confusion).

@Mariatta Mariatta merged commit d618c8c into python:master May 23, 2017
@Mariatta
Copy link
Member

Thanks @aktech

ambv pushed a commit that referenced this pull request May 23, 2017
ambv pushed a commit that referenced this pull request May 23, 2017
@ncoghlan
Copy link
Contributor

Added the sprint label, as this PR was submitted at the PyCon Pune 2017 core development sprint.

akruis pushed a commit to akruis/cpython that referenced this pull request Dec 20, 2017
This fix prevent a NULL-pointer access (SEGFAULT), if a thread
terminates with a MemoryError exception.
akruis pushed a commit to akruis/cpython that referenced this pull request Mar 25, 2018
This fix prevent a NULL-pointer access (SEGFAULT), if a thread
terminates with a MemoryError exception.
(cherry picked from commit bcd724c)
jaraco pushed a commit that referenced this pull request Dec 2, 2022
Merge the PR if:
- PR has "awaiting merge" and "automerge" labels, and
- all CI status checks have passed.

It will:
- replace `#` with `GH-`
- get the commit message from PR title and description

Closes python/bedevere#14
Closes python/core-workflow#29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants