You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
csvwriter.writerow()'s return type is undocumented #78894
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?
remilapeyre commented on Mar 13, 2019
remilapeyremannequin
Mannequin
More actions
Issue bpo-27497 is related, it adds documentation a return value and documentation to csv.DictWriter.writeheader which uses writerow internally.
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?
Activity
nchammas commentedon Sep 17, 2018
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().
nchammas commentedon Sep 17, 2018
Looks like it's bytes written, not characters:
remilapeyre commentedon Mar 12, 2019
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?
remilapeyre commentedon Mar 13, 2019
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?
nchammas commentedon Mar 13, 2019
Nope, go ahead.
slateny commentedon May 5, 2022
Resolved by #12306