Giter VIP home page Giter VIP logo

heist's Introduction

Heist

python

This package provides tools for extracting financial data from PDF files. With this data you may search for specific transactions or write out CSV files for Excel or Google Sheets.


Statement Classes

Review your PDF file to understand how each transaction line is specified as you will likely need to subclass and create custom regex patterns to fit your statement needs.

The finance module contains the base class for financial statements. There are a few examples of sub-classed statements that illustrate how to add new financial institutions. When subclassing the StatementBase class as a new financial statement class, you must implement the _get_transaction_details() and _parse_transaction() methods.

Regex Patterns

Statement classes also have two regex attributes which define the pdf transaction formatting __re_page_end__ and __re_transaction__

The pattern for extracting the date, description, amount, and balance would look something like this:

03/25       Example charge description                -10.00         123.45
__re_transaction__: str = (
    r"(?P<date>\d+/\d+)\s+"
    r"(?P<desc>.+)\s+"
    r"(?P<amount>.*[\d]+\.[\d]+)\s+"
    r"(?P<balance>[\d\.,\-]+)"
)

Example Usage and Searching

from pathlib import Path

from heist import finance, expense, sheet
from heist.finance import TransactionType

# batch all transactions from multiple lenders into a list
transactions: list[TransactionType] = expense.get_chase_checking("c:/path/to/pdf/files")
transactions.extend(expense.get_chase_amazon("c:/path/to/pdf/files"))
transactions.extend(expense.get_barclays_arrivalplus("c:/path/to/pdf/files"))

# wildcard search for transactions using a string or list of strings
vehicle_reg: list[dict] = finance.search_transactions("dmv", transactions)
amazon: list[dict] = finance.search_transactions(["amazon", "amzn"], transactions)
apple: list[dict] = finance.search_transactions("apple.com", transactions)
google: list[dict] = finance.search_transactions("google", transactions)
subscriptions: list[dict] = finance.search_transactions(["netflix", "openai", "hulu", "spotify"], transactions)

# specify and create the csv destination folder
csv_folder: Path = Path("c:/path/to/write/csv/files")
csv_folder.mkdir(parents=True, exist_ok=True)

# csv column sort order based on transaction data
sort_list: list[str] = ["bank", "date", "description", "amount", "miles"]
sheet.write_csv(csv_folder.joinpath("all_transactions.csv"), transactions, sort_list=sort_list)
sheet.write_csv(csv_folder.joinpath("vehicle_registration.csv"), vehicle_reg, sort_list=sort_list)
sheet.write_csv(csv_folder.joinpath("amazon.csv"), amazon, sort_list=sort_list)
sheet.write_csv(csv_folder.joinpath("apple.csv"), apple, sort_list=sort_list)
sheet.write_csv(csv_folder.joinpath("google.csv"), google, sort_list=sort_list)
sheet.write_csv(csv_folder.joinpath("subscriptions.csv"), subscriptions, sort_list=sort_list)

Dependencies


Social

github twitter


Changelist

  • 2024-24-03: Initial commit

heist's People

Contributors

stylerhall avatar

Stargazers

Peter Abbasi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.