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-parserVerified import paths — ran on the pinned version, not inferred.
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.
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.
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=",")`).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: ...`
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).
Use the correct import statement: `from price_parser import Price`
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())`Provide a `decimal_separator` hint when parsing such strings: `price = Price.fromstring(',89 €', decimal_separator=',')`No dependency data recorded yet.