Message124678
Skip, I'm WRITING, not reading.. Please read the 3.1 documentation for csv.writer. It does NOT mention newline='', and neither does the example. Please fix.
Other problems with the examples: (1) They encourage a bad habit (open inside the call to reader/writer); good practice is to retain the reference to the file handle (preferably with a "with" statement) so that it can be closed properly. (2) delimiter=' ' is very unrealistic.
The documentation for both 2.x and 3.x should be much more explicit about what is needed in open() for csv to work properly and portably:
2.x read: use mode='rb' -- otherwise fail on Windows
2.x write: use mode='wb' -- otherwise fail on Windows
3.x read: use newline='' -- otherwise fail unconditionally(?)
3.x write: use newline='' -- otherwise fail on Windows
The 2.7 documentation says """If csvfile is a file object, it must be opened with the 'b' flag on platforms where that makes a difference""" ... in my experience, people are left asking "what platforms? what difference?"; Windows should be mentioned explicitly. |
|
Date |
User |
Action |
Args |
2010-12-26 20:52:51 | sjmachin | set | recipients:
+ sjmachin, skip.montanaro, baloan, eric.araujo, zacktu |
2010-12-26 20:52:51 | sjmachin | set | messageid: <1293396771.67.0.157981030344.issue7198@psf.upfronthosting.co.za> |
2010-12-26 20:52:49 | sjmachin | link | issue7198 messages |
2010-12-26 20:52:49 | sjmachin | create | |
|