Skip to content

Add float precision variable to csv.writer / reader #110852

Description

@chaeynz

Feature or enhancement

Proposal:

var_float_precision = 2

def format_item(item):
        if isinstance(item, float):
            return f"{item:.(var_float_precision)f}"

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

Links to previous discussion of this feature:

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions