This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年12月10日 18:49 by rhettinger, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg149179 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2011年12月10日 18:49 | |
The csv.writer needs a special case for floats to print them to full precision. See http://stackoverflow.com/a/8455313/1001643 In Py2.7, the csv.writer converts floats to strings using str(). This will store 1323494016.8556759 as '1323494016.86' and unnecessarily throw away precision. In Py3.2, this isn't a problem because float.__str__ now returns full precision, the same a float.__repr__. |
|||
| msg149221 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2011年12月11日 10:24 | |
+1 for fixing this. |
|||
| msg149277 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2011年12月12日 06:31 | |
New changeset bf7329190ca6 by Raymond Hettinger in branch '2.7': Issue #13573: The csv.writer now uses the repr() for floats rather than str(). http://hg.python.org/cpython/rev/bf7329190ca6 |
|||
| msg149643 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2011年12月16日 23:31 | |
Is this complete and ready to close, or does the doc need a note? |
|||
| msg149646 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2011年12月17日 00:01 | |
The code is fixed. Am leaving this open until I have a chance to see if anything in the docs need to be updated. |
|||
| msg260965 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2016年02月28日 05:00 | |
csv.writer() documentation says: "All other non-string data are stringified with str() before being written." https://docs.python.org/2.7/library/csv.html#csv.writer I guess adding a sentence to document the special case for floats wouldn't hurt. |
|||
| msg260968 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年02月28日 07:35 | |
New changeset d3ac0214b7b8 by Raymond Hettinger in branch '2.7': Issue 13573: Document that csv.writer uses str() for floats instead of repr(). https://hg.python.org/cpython/rev/d3ac0214b7b8 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:24 | admin | set | github: 57782 |
| 2016年02月28日 08:54:33 | berker.peksag | set | stage: needs patch -> resolved |
| 2016年02月28日 07:35:20 | rhettinger | set | status: open -> closed resolution: fixed |
| 2016年02月28日 07:35:04 | python-dev | set | messages: + msg260968 |
| 2016年02月28日 05:00:24 | berker.peksag | set | nosy:
+ berker.peksag messages: + msg260965 keywords: + easy stage: needs patch |
| 2011年12月17日 00:01:16 | rhettinger | set | messages: + msg149646 |
| 2011年12月16日 23:31:20 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg149643 |
| 2011年12月12日 06:31:22 | python-dev | set | nosy:
+ python-dev messages: + msg149277 |
| 2011年12月11日 10:24:34 | mark.dickinson | set | nosy:
+ mark.dickinson messages: + msg149221 |
| 2011年12月10日 18:49:54 | rhettinger | create | |