q2numfmt
q2numfmt is a lightweight Python package for formatting numeric data using Excel-style number format strings. It follows the ECMA-376 - Office Open XML file formats - 5th edition, December 2021 specification—the same standard used by Microsoft Excel to format numbers.
Features
- Format integer, float, string, or
Decimalvalues. - Supports custom Excel-like format strings (e.g.
"0.00","0%","$#,##0.00"). - Implements rules from ECMA-376 Part 1, Section 18.8.31 (
numFmts). - No external dependencies.
- Ideal for spreadsheet tools, reports, exports, and other data presentation needs.
Installation
pip install q2numfmt
Usage
from q2numfmt import format_number
print(format_number(1234.567, "#,##0.00")) # "1,234.57"
print(format_number("0.056", "0.0%")) # "5.6%"
print(format_number(-1234.5, "$#,##0.00")) # "-$1,234.50"
print(format_number(0, '[Green]0.00;[Red]-0.00')) # "0.00"
API
format_number(value, format_string)
Formats a number using an Excel-style number format string.
value: int, float, str, or decimal.Decimal
format_string: A string format as defined in Excel / ECMA-376
Returns a str with the formatted result.
Example Format Strings
| Format String | Input | Output |
|---|---|---|
| 0.00 | 12.3 | 12.30 |
| #,##0 | 12345 | 12,345 |
| 0.0% | 0.1234 | 12.3% |
| $#,##0.00 | -1234.5 | -$1,234.50 |
| 1234.59 | ####.# | 1234.6 |
| [Red]-0.0 | -5.5 | -5.5 |
Specification
The package is based on:
ECMA-376-1:2016, Part 1 – Office Open XML File Formats
Section 18.8.31: numFmts (Custom Number Formats in Excel)
License
This project is licensed under the MIT License – see the LICENSE file for details.
Links
PyPI: https://pypi.org/project/q2numfmt
GitHub: https://github.com/AndreiPuchko/q2numfmt
Author
Andrei Puchko GitHub: https://github.com/AndreiPuchko
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page or submit a pull request.
Metadata
Release files for q2numfmt 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| q2numfmt-0.1.1.tar.gz | 8.1 kB | Without provenance | Details for q2numfmt-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| q2numfmt-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for q2numfmt-0.1.1-py3-none-any.whl |
Total release size: 16.6 kB
Release files / q2numfmt-0.1.1.tar.gz
| Download URL | q2numfmt-0.1.1.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2e030c94e137b01de6d6e6a5763ec911fb6f18601890267f7c4a8d7f4bef0cd
|
|
BLAKE2b-256 checksum How to use checksums |
9d8a878814a513b98a077d7b728abe01e55118738f7cc98a7f922db9e4a6e4c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.0 CPython/3.11.7 Windows/10
|
Release files / q2numfmt-0.1.1-py3-none-any.whl
| Download URL | q2numfmt-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f0b3f7ecf13f134d8cf947d33577ddf56d9305f9d0b806e8fa77520818c64e68
|
|
BLAKE2b-256 checksum How to use checksums |
811257f176e62bf5b23115c80f3623e7da45ab82a47e1783b0e40c0468ee489f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.0 CPython/3.11.7 Windows/10
|
Security for q2numfmt 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.