Skip to main content

Convert numerical amounts to words with support for Indian and Bangladeshi currency formats/numberinc system

Project description

num2words-BD-INR

A Python package to convert numerical amounts to words with special handling for Indian Rupees (INR) and Bangladeshi Taka (BDT) with Numeric System Like Lakh, Crore. Useful for financial documents, invoices, and official reports where amounts need to be written out in words.

Features

  • 💰 Converts numerical amounts to words with proper currency formatting/numeric system(Lakh, Crore)
  • 🇧🇩🇮🇳 Special handling for Indian Rupees (INR) and Bangladeshi Taka (BDT)
  • 🌐 Supports various languages through the num2words library
  • 🛠️ Multiple formatting options:
    • Rounding amount values
    • Removing fractional parts
    • Title case or first letter capitalization
    • Custom prefixes and suffixes
    • Custom separators for integer parts

Installation

pip install num2words-BD-INR

Quick Start

from num2words_bd_inr import amount_in_words

# Basic usage
result = amount_in_words(1234.56, 'INR', 'en')
print(result)  # "One Thousand Two Hundred Thirty Four Rupees Fifty Six Paisa"

Examples

Different Currencies

# Indian Rupees
amount_in_words(1234.56, 'INR', 'en')  
# "One Thousand Two Hundred Thirty Four Rupees Fifty Six Paisa"

# Bangladeshi Taka
amount_in_words(1234.56, 'BDT', 'en')  
# "One Thousand Two Hundred Thirty Four Taka Fifty Six Paisa"

# US Dollars
amount_in_words(1234.56, 'USD', 'en')  
# "One Thousand Two Hundred Thirty Four Dollars Fifty Six Cents"

Formatting Options

# With rounding
amount_in_words(1234.56, 'BDT', 'en', rounding=True)
# "One Thousand Two Hundred Thirty Five Taka"

# Remove fractional part
amount_in_words(1234.56, 'EUR', 'en', rem_fraction=True)
# "One Thousand Two Hundred Thirty Four Euros"

# Custom text styling
amount_in_words(1000.00, 'USD', 'en', title_style=True, prefix_val="Only")
# "Only One Thousand Dollars"

# With capitalization of only first letter
amount_in_words(5432.10, 'GBP', 'en', cap_style=True)
# "Five thousand four hundred thirty two pounds ten pence"

# With custom integer separator
amount_in_words(1234.56, 'USD', 'en', int_sep=",")
# "One Thousand, Two Hundred Thirty Four Dollars Fifty Six Cents"

API Reference

amount_in_words()

amount_in_words(
    amount: float,
    currency: str,
    lang: str,
    rem_fraction: bool = False,
    rounding: bool = False,
    title_style: bool = False,
    cap_style: bool = False,
    prefix_val: Optional[str] = None,
    subfix_val: Optional[str] = None,
    int_sep: Optional[str] = None,
    decimal_sep: Optional[str] = None
) -> str

Parameters

Parameter Type Description Default
amount float The numerical amount to convert to words Required
currency str Currency code ('INR', 'BDT', or other standard currency codes) Required
lang str Language code for conversion (e.g., 'en', 'bn') Required
rem_fraction bool Whether to remove fractional parts False
rounding bool Whether to round the amount (takes precedence over rem_fraction) False
title_style bool Whether to apply title case to output False
cap_style bool Whether to capitalize first letter only False
prefix_val str Text to add before the amount words None
subfix_val str Text to add after the amount words None
int_sep str Separator for integer parts (e.g., 'and', ',') None
decimal_sep str Separator for decimal parts None

Return Value

A string containing the amount expressed in words according to the specified formatting options.

Important Notes

  • If both rounding and rem_fraction are set to True, rounding takes precedence.
  • The package correctly handles currency-specific terms (e.g., "Rupee"/"Paisa" for INR, "Taka"/"Paisa" for BDT).
  • Default text styling applies title case if no styling option is specified.

Requirements

  • Python 3.10 or above
  • num2words package

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Issues and Feature Requests

If you find any bugs or have a feature request, please open an issue on the GitHub repository.

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

num2words_bd_inr-0.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

num2words_bd_inr-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file num2words_bd_inr-0.1.0.tar.gz.

File metadata

  • Download URL: num2words_bd_inr-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for num2words_bd_inr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 012f29d4c486d89bd69d03ea505e95c0f52ba43b0a71eed28971c2eb065f3949
MD5 40d18278e09c03844270058381bd8c87
BLAKE2b-256 971cc6f4231a70c7cbde4a01fee295e6c0dab25051da2ec902cb25be473c52fa

See more details on using hashes here.

File details

Details for the file num2words_bd_inr-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for num2words_bd_inr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79c6f9068bee7dc018595a4f83c86b15aaccc3e650c5ea31b84ed3a5718485ad
MD5 ffcad70bb29e75406c7582253e45caa3
BLAKE2b-256 b86b8dd5440c750c1b8e58168aad6a91c4d5cdf84e38d4025cafc9321d1fe7b8

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