72 lines
1.6 KiB
Plaintext
72 lines
1.6 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"op=Operation.Transactions, params=None\n",
|
|
"[]\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import difflib\n",
|
|
"import dotenv\n",
|
|
"import os\n",
|
|
"\n",
|
|
"from pfbudget.common.types import Operation\n",
|
|
"from pfbudget.core.manager import Manager\n",
|
|
"\n",
|
|
"dotenv.load_dotenv()\n",
|
|
"\n",
|
|
"manager = Manager(os.environ.get(\"DEFAULT_DB\", \"\"), 2)\n",
|
|
"transactions = manager.action(Operation.Transactions)\n",
|
|
"if transactions is None:\n",
|
|
" transactions = []\n",
|
|
"\n",
|
|
"matches = []\n",
|
|
"\n",
|
|
"for t in transactions:\n",
|
|
" found = False\n",
|
|
" for m in matches:\n",
|
|
" if difflib.get_close_matches(t[\"description\"], [m[0]], cutoff=0.6):\n",
|
|
" m[1] += 1\n",
|
|
" found = True\n",
|
|
" break\n",
|
|
" if not found:\n",
|
|
" matches.append([t[\"description\"], 1])\n",
|
|
"\n",
|
|
"# matches = []\n",
|
|
"print(sorted(matches, key=lambda m: m[1], reverse=True))\n"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "pf-notebooks-34EKrqJg-py3.10",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.10.10"
|
|
},
|
|
"orig_nbformat": 4
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|