Skip to main content

Generalize texts from payment card transactions

Project description


Build Status Scrutinizer Code Quality Code Coverage

Python package to generalize texts from payments.


When categorizing payments, I want to avoid categorizing the same type of expense multiple times. Often, the only information we have about a payment is the date, amount and a slightly cryptic string. For example, I recently bought some plane tickets using Ticket. On my account statement, that produced a string similar to this one: *4274 25.06 NOK 4101.00 WWW.TICKET.NO Kurs: 1.0000.

Now, when I put this payment in the Travel category, I'd like all future payments to the same vendor to be automatically put in the same category. But the next time I buy a plane ticket from them, the date and amount will be different. Also, the leading card number may be different, too. So, in order to automate the categorization, we need to generalize the text. In other words, *4274 25.06 NOK 4101.00 WWW.TICKET.NO Kurs: 1.0000 needs to become WWW.TICKET.NO. That's what this tiny package does.


Use Pipenv: pipenv install paytext


from paytext import PaymentText

payment_text: PaymentText = PaymentText(
    '*4274 25.06 NOK 4101.00 WWW.TICKET.NO Kurs: 1.0000',

print(payment_text) # Output: '*4274 25.06 NOK 4101.00 WWW.TICKET.NO Kurs: 1.0000' 


print(payment_text) # Output: 'WWW.TICKET.NO'

Known limitations

I've mostly had strings from transactions with Norwegian merchants and banks to work with, so this package probably won't work as well with other languages/locales. If you find strings that it doesn't handle well, please open an issue on GitHub.

Running tests

Run the command nosetests.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for paytext, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size paytext-0.0.1-py3-none-any.whl (5.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size paytext-0.0.1.tar.gz (4.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page