Skip to main content

Module to parse a number-string to a float or decimal.

Project description


pypi python pytest coverage maintainability

Parse financial strings to number objects


pip install finparse


import finparse

# => 1234567.89

finparse.parse("€1.234.567,89", decimal=",")
# => 1234567.89

# => -1234567.89

import decimal

finparse.parse("$1,234,567.89", cast=decimal.Decimal)
# => Decimal('1234567.89')


Pandas' read_csv() function provdides a converters argument that applies a function to the given column.

Using the example CSV file ./tests/example.csv, we can see the following behavior:

import pandas

df = pandas.read_csv('./tests/example.csv')

# =>        Acct     Balance
#    0   Savings  $1,234.567
#    1  Checking    ($0.987)

With the converters argument we can parse these values to floats:

import finparse
import pandas

df = pandas.read_csv('./tests/example.csv', converters={'Balance': finparse.parse})

# =>        Acct   Balance
#    0   Savings  1234.567
#    1  Checking    -0.987

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

finparse-0.1.4.tar.gz (4.9 kB view hashes)

Uploaded source

Built Distribution

finparse-0.1.4-py3-none-any.whl (3.2 kB view hashes)

Uploaded py2 py3

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