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
Add float precision variable to csv.writer / reader #110852
I just now have the situation, that I want to print a 0 as 0.00, because the ERP system only detects it that way.
Please add the ability to define a custom precision for float numbers. Just recently the QUOTE_STRINGS was introduced into python, but when I manually format it to a 0.00 using {:.2f}".format(var)) it will obviously become a string, therefore it will print the variable in Quotes, which the ERP system again, does not detect.
Thank you!
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
gh-155097 (PR #155099) adds a formatter parameter to csv.writer which replaces the str() call. Quoting is still decided by the original value, so a formatted number stays unquoted — which is exactly what '{:.2f}'.format(v) in your own code cannot do:
Activity
serhiy-storchaka commentedon Aug 3, 2026
gh-155097 (PR #155099) adds a
formatterparameter tocsv.writerwhich replaces thestr()call. Quoting is still decided by the original value, so a formatted number stays unquoted — which is exactly what'{:.2f}'.format(v)in your own code cannot do:The first argument is the 0-based column index, so the precision can differ per column. Strings and
Nonenever reach the formatter.