Registry / serialization / price-parser

price-parser

JSON →
library0.5.1pypypi✓ verified 87d ago

Price-parser is a lightweight Python library designed for robustly extracting price amounts and currency symbols from raw text strings. It intelligently handles various international formats for decimal and thousand separators, making it particularly useful for cleaning price data obtained from web scraping. The library returns a `Price` object containing the numeric amount (as a `Decimal`) and the detected currency. The current version is 0.5.1, released on March 19, 2026, and it maintains an active development and release cadence.

pip install price-parser
INSTALL
IMPORT
SIG · PRICE-PARSER
P
price-parser
serializationpythonv0.5.1
Install
1.6s avg
Import
119ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.123s · 18.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.114s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Price
from price_parser import Price
parse_price
from price_parser import parse_price
An alias for Price.fromstring()

Demonstrates basic price and currency extraction using `Price.fromstring()`, handling various formats, applying currency hints, and explicitly setting the decimal separator. It also shows how to access both Decimal and float representations of the amount.

from price_parser import Price # Basic usage price = Price.fromstring("22,90 €") print(f"Amount: {price.amount}, Currency: {price.currency}") # Handling different formats price2 = Price.fromstring("Price: $119.00") print(f"Amount: {price2.amount}, Currency: {price2.currency}") # Using currency hints price3 = Price.fromstring("34.99", currency_hint="руб. (шт)") print(f"Amount: {price3.amount}, Currency: {price3.currency}") # Explicitly setting decimal separator price4 = Price.fromstring("1.234,56 SEK", decimal_separator=",") print(f"Amount: {price4.amount}, Currency: {price4.currency}") # Accessing float value (use with caution for financial calculations) price5 = Price.fromstring("€123.45") print(f"Float Amount: {price5.amount_float}")
Debug
Known issues
gotchaThe `Price.amount` attribute returns a `Decimal` object for precision. While `Price.amount_float` is available, using floats for financial calculations can lead to precision errors. Prefer `Decimal` for accuracy.
fix
Always use `price.amount` (Decimal) for calculations to avoid floating-point inaccuracies. Convert to float (`price.amount_float`) only when necessary for external systems that require floats.
affects: All
gotchaIn ambiguous cases, especially with mixed international numeral formats (e.g., '1.234,56' vs '1,234.56'), the library might guess the decimal separator incorrectly. This is more common when no explicit currency symbol guides the parsing.
fix
For improved reliability, provide the `decimal_separator` argument to `Price.fromstring()` if you know the exact separator used in the input string (e.g., `Price.fromstring("1.234,56", decimal_separator=",")`).
affects: All
gotchaIf the library cannot confidently detect an amount or currency from the input string, the respective `amount` or `currency` attributes of the returned `Price` object will be `None`.
fix
Always check for `None` values on `price.amount` and `price.currency` after parsing to ensure successful extraction before further processing. Example: `if price.amount is not None: ...`
affects: All
gotchaThere are multiple Python packages (and even libraries in other languages) named 'price-parser' or similar. Ensure you are installing and using the correct 'scrapinghub/price-parser' library to avoid unexpected behavior or API differences.
fix
Verify the import path `from price_parser import Price` and the project's GitHub repository `https://github.com/scrapinghub/price-parser` matches your intended library. If you need Pydantic compatibility, consider `price-parser-reworkd` (a different library).
affects: All
Errors
Common errors & fixes
ImportError: cannot import name 'Price' from 'price_parser'
Developers often confuse the package name (`price-parser`) with the main class name or try to import a non-existent class like `PriceParser` instead of the correct `Price` class.
fix
Use the correct import statement: `from price_parser import Price`
AttributeError: 'NoneType' object has no attribute 'lower'
The `Price.fromstring()` method returns a `Price` object where the `amount` or `currency` attributes can be `None` if the price or currency cannot be successfully extracted from the input string. Attempting to call a string method (like `lower()`) on a `None` value will raise this error.
fix
Always check if `price.amount` or `price.currency` is not `None` before attempting operations on them: `price = Price.fromstring('invalid string'); if price.currency: print(price.currency.lower())`
price-parser numbers starting with ',' as decimal delimiter parse as wrong value
While `price-parser` is designed to handle various international formats, some edge cases, like a price string starting directly with a decimal comma (e.g., ',89'), might be misinterpreted, leading to incorrect parsing of the amount (e.g., parsing ',89' as '89').
fix
Provide a `decimal_separator` hint when parsing such strings: `price = Price.fromstring(',89 €', decimal_separator=',')`
Upgrade
Version history
0.5.1latest on PyPI · released Mar 19, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
36 hits · last 30 days
node
34
Resources
price-parser — pip install price-parser · libregistry