[issue40013] CSV DictReader parameter documentation
New submission from Moshe Sambol <moshe.sambol@gmail.com>: The csv.DictReader constructor takes two optional parameters, restkey and restval. restkey is documented well, but restval is not: "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 to None). If a non-blank row has fewer fields than fieldnames, the missing values are filled-in with None." Since restval is not mentioned here, the reader may assume that the next sentence applies to it: "All other optional or keyword arguments are passed to the underlying reader instance." But this is not the case for restval. I suggest that the text be amended to "If a non-blank row has fewer fields than fieldnames, the missing values are filled-in with the value of restval (which defaults to None)." ---------- assignee: docs@python components: Documentation messages: 364598 nosy: Moshe Sambol, docs@python priority: normal severity: normal status: open title: CSV DictReader parameter documentation versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40013> _______________________________________
Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment: This looks like a good clarification to me where None is clarified that it's the value of restval. DictWriter has a similar doc "The optional restval parameter specifies the value to be written if the dictionary is missing a key in fieldnames" at https://docs.python.org/3/library/csv.html#csv.DictWriter ---------- nosy: +xtreak _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40013> _______________________________________
Change by Juhana Jauhiainen <juhana.jauhiainen@gmail.com>: ---------- keywords: +patch nosy: +Juhana.Jauhiainen nosy_count: 3.0 -> 4.0 pull_requests: +18459 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19099 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40013> _______________________________________
Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment: New changeset 4b3252cb764807fdb3a661b458d43e4af55cf4df by Juhana Jauhiainen in branch 'master': bpo-40013: Clarify documentation of restval in csv.DictReader (GH-19099) https://github.com/python/cpython/commit/4b3252cb764807fdb3a661b458d43e4af55... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40013> _______________________________________
Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- nosy: +miss-islington nosy_count: 4.0 -> 5.0 pull_requests: +18502 pull_request: https://github.com/python/cpython/pull/19141 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40013> _______________________________________
Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +18503 pull_request: https://github.com/python/cpython/pull/19142 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40013> _______________________________________
Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment: New changeset 2227c1a4ca87034ed9eac55eb260a5fb0a04375d by Miss Islington (bot) in branch '3.8': bpo-40013: Clarify documentation of restval in csv.DictReader (GH-19099) (GH-19141) https://github.com/python/cpython/commit/2227c1a4ca87034ed9eac55eb260a5fb0a0... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40013> _______________________________________
Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment: New changeset e5527f0edf7edc98e5e859b5fe823878684b4b6a by Miss Islington (bot) in branch '3.7': bpo-40013: Clarify documentation of restval in csv.DictReader (GH-19099) (GH-19142) https://github.com/python/cpython/commit/e5527f0edf7edc98e5e859b5fe823878684... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40013> _______________________________________
Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment: Closing this as fixed. Thanks Moshe for the report. ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed title: CSV DictReader parameter documentation -> CSV DictReader restval parameter documentation type: -> enhancement versions: -Python 3.5, Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40013> _______________________________________
participants (4)
-
Juhana Jauhiainen -
Karthikeyan Singaravelan -
miss-islington -
Moshe Sambol