Skip to main content

Parse numbers with different formatting to builtin python Decimal.

Project description

decimify

CI Pypi Versions License

Parse numbers with different formatting to builtin python Decimal.

A decimal separator is a symbol used to separate the integer part from the fractional part of a number written in decimal form (e.g. "." in 12.45). Different countries officially designate different symbols for use as the separator. The choice of symbol also affects the choice of symbol for the thousands separator used in digit grouping.

Some examples of large number presentations in all around the world:

Large Number Locale
1,234,567.89 Australia, Cambodia, Canada (English-speaking; unofficial), China, Cyprus (currency numbers), Hong Kong, Iran, Ireland, Israel, Japan, Korea, Macau (in Chinese and English text), Malaysia, Malta, Mexico, Namibia, New Zealand, Pakistan, Peru (currency numbers), Philippines, Singapore, South Africa (English-speaking; unofficial), Taiwan, Thailand, United Kingdom and other Commonwealth states except Mozambique, United States.
1234567.89 SI style (English version), Canada (English-speaking; official), China, Estonia (currency numbers), Hong Kong (in education), Mexico, Namibia, South Africa (English-speaking; unofficial), Sri Lanka, Switzerland (in federal texts for currency numbers only), United Kingdom (in education), United States (in education).
1234567,89 SI style (French version), Albania, Belgium (French), Brazil, Bulgaria, Canada (French-speaking), Costa Rica, Croatia, Czech Republic, Estonia, Finland, France, Hungary, Italy (in education), Latin America, Latin Europe, Latvia, Lithuania, Macau (in Portuguese text), Mozambique, Norway, Peru, Poland, Portugal, Russia, Serbia (informal), Slovakia, South Africa (officiale RAE and CSIC), Sweden, Switzerland (in federal texts, except currency numbers), Ukraine, Vietnam (in education).
1.234.567,89 Austria, Belgium (Dutch), Bosnia and Herzegovina, Brazil (informal and in technology), Chile, Colombia, Croatia (in bookkeeping and technology), Denmark, Germany, Greece, Indonesia, Italy, Latin America (informal), Netherlands, Romania, Slovenia, Serbia, Spain (used until 2010, inadvisable use according to the RAE and CSIC), Turkey, Uruguay, Vietnam.
1,234,567·89 Malaysia, Philippines (uncommon today), Singapore, United Kingdom (older, typically handwritten; in education)
12,34,567.89 Bangladesh, India, Nepal, Pakistan (see Indian numbering system).
1234567.89 Bangladesh, India, Nepal, Pakistan (see Indian numbering system).

Reference

decimify aims to solve this problem by automatically converting many common formats into python Decimal.

Without having any external dependencies. It uses builtin python functions to convert string representation of numbers to Decimal.

Installation

pip install -U decimify

Usage

from decimify import decimify

my_decimal = decimify("23 234.678,00")
my_decimal
# Decimal('23234678.00')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

decimify-0.3.0.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

decimify-0.3.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file decimify-0.3.0.tar.gz.

File metadata

  • Download URL: decimify-0.3.0.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for decimify-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4faea7f93efe1f6a22f2a50ea2e0dd4fb966282b763305fc41f486e6fa9f2733
MD5 a3bc57baa712127b2a79786ff894bbb1
BLAKE2b-256 195a97e370172f7a4cb8b0c15a31ac07eb466d8daea5c5d573ae1d5a8c61c484

See more details on using hashes here.

File details

Details for the file decimify-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: decimify-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for decimify-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d4174466c305b8552c904e56184da8c6ae637acc14bb2e07f60c78df2a943b4
MD5 b84e23974b2df4f02d7b6cf668f6700f
BLAKE2b-256 8ac7eedb83f5190e0523bd87c7030a3d8f54f97e300d4a1945eb6e1cf7bb2eb1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page