Skip to main content

Parse numbers with different formatting to builtin python Decimal.

Project description

decimify

CI Pypi Versions Codecov 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.2.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

decimify-0.2.3-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: decimify-0.2.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for decimify-0.2.3.tar.gz
Algorithm Hash digest
SHA256 6a569490bffb81a96c9e042a048f2bc0994ef151b7bf3c7d19f382dd1fffb3d7
MD5 99021a624562bd52ae1a2f03fae9af3f
BLAKE2b-256 388a60fd7dcd50727d26238082405816c30918716826c49fe503ac187fc2604f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: decimify-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for decimify-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cf0a6e5fc85ca414ffc5d07c4965f0a71569b4f26dbed4ac61b926a527c021e9
MD5 f7c22c45dd2be660aa6f9399a1c57aab
BLAKE2b-256 28c6b3fe715a3d07bf39592904eb01cf6f36a6a1790d24c66ce0ca2556eebe43

See more details on using hashes here.

Supported by

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