Skip to content

Preserve numeric values in csvstat decimal formatting - #1406

Open
Grivn wants to merge 1 commit into
wireservice:masterfrom
Grivn:fix/csvstat-decimal-output
Open

Grivn wants to merge 1 commit into
wireservice:masterfrom
Grivn:fix/csvstat-decimal-output

Conversation

@Grivn

@Grivn Grivn commented Nov 29, 2026

Copy link
Copy Markdown

With a column containing 9007199254740993.125 and 9007199254740994, csvstat --min --no-grouping-separator prints the second value. The aggregation returns the correct Decimal, but Python's %f converts it to a float during formatting.

Format fixed-point values directly as decimals and then apply the locale's decimal point and grouping. Also restrict zero trimming to the fractional digits. With --decimal-format '%.3e', a minimum of ten billion now prints as 1.000e+10. Previously the exponent lost its final zero and the result read 1.000e+1.

The new CLI regressions cover the large minimum, an explicit format with sign and padding, and positive and negative exponents. The full suite passed on macOS with CPython 3.10–3.14 and PyPy 3.11 (369 passed, 4 skipped per interpreter).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant