明細 CSV の支出カテゴリ分け(ルール編集式)

Expense CSV categorizer with editable rules

銀行やクレジットカードの明細 CSV を、編集できるルールファイル(キーワード・正規表現)で費目に分け、月別・費目別の合計と未分類の一覧を出します。

ClaudeHermes AgentCodexCursorMIT(改変・再配布・商用利用可)Python

できること

カード明細や銀行の入出金明細を、家計簿や経費の集計に使える形にします。

  • Shift_JIS の明細や、表の上にカード名などの行がある CSV でも見出し行を自動で見つけ、日付・利用店名・金額・入金の列を対応づけ
  • 「1,234円」「¥1,234」「▲500」「(500)」などの金額表記を読み取り、支出はプラス、返金・入金はマイナスに統一
  • ルールファイル(CSV)のキーワードや正規表現で費目を判定。全角半角・大文字小文字の違いは無視するので、半角カナの「セブンイレブン」も一致します
  • 主なコンビニ、スーパー、交通系 IC、携帯会社、サブスクなどを含む日本向けの初期ルール付き
  • 月別・費目別の合計(支出/返金・入金/差引)と、どのルールで分類したかの記録
  • どのルールにも当たらなかった明細を店名ごとにまとめた unknown.csv

使い方

python scripts/expense_categorize.py card.csv bank.csv --rules my_rules.csv --out-dir out/

エージェントが未分類の店名について費目を提案し、あなたが確認したものをルールファイルに追加して再実行します。繰り返すほど自動で分類できる明細が増えます。

必要な環境

  • Python 3(標準ライブラリのみ)

注意点

  • 明細ファイルとルールファイルは読むだけで変更しません。
  • カード代金の引き落としや自分の口座間の振替は、費目名を _ で始めると合計から外せます(二重計上を防げます)。
  • 初期ルールはあくまで出発点です。短いキーワードは別の店に当たることがあるので、記録されたルールを確認してください。
  • 集計は取引日の月で行います。税務・会計の判断は行いません。
English description

Categorizes bank and credit card statement CSV rows with an editable keyword/regex rules file, then outputs monthly totals per category and a list of unknown rows to classify.

What it does

Turns card and bank statements into numbers you can use for a household budget or expense summary.

  • Finds the header row automatically, even in Shift_JIS files with card-name lines above the table, and maps date, merchant, amount and deposit columns
  • Reads amounts written with commas, a yen sign or the kanji yen suffix, triangle minus signs and parentheses; spending is positive, refunds and income are negative
  • Categorizes with keywords or regular expressions from a CSV rules file. Full-width/half-width and case differences are ignored, so half-width katakana merchant names match too
  • Ships with starter rules for common Japanese convenience stores, supermarkets, transit IC cards, mobile carriers and subscriptions
  • Writes monthly totals per category (spent, refunds or income, net) and records which rule matched each row
  • Groups unmatched rows by merchant in unknown.csv

How to use

python scripts/expense_categorize.py card.csv bank.csv --rules my_rules.csv --out-dir out/

The agent proposes categories for unknown merchants, adds the ones you confirm to your rules file, and re-runs. Each round leaves fewer unknown rows.

Requirements

  • Python 3 (standard library only)

Caveats

  • Statement files and the rules file are only read, never changed.
  • Categories whose name starts with _ are excluded from totals; use them for card bill payments and transfers between your own accounts to avoid double counting.
  • Starter rules are a starting point. Short keywords can match the wrong merchant, so check the recorded rule.
  • Totals use the transaction date month. This is not tax or accounting advice.

インストール方法

  1. ダウンロードしたZIPを展開します(中に expense-csv-categorizer/ フォルダと SKILL.md があります)。
  2. フォルダごと、使うエージェントのスキル置き場にコピーします。
    • Claude:~/.claude/skills/(プロジェクト単位なら .claude/skills/)
    • Hermes Agent:~/.hermes/skills/
    • Codex:~/.agents/skills//Cursor:~/.cursor/skills/
    • Claude アプリ(claude.ai):「カスタマイズ → スキル」からZIPをアップロード
  3. エージェントを再起動し、スキル一覧に表示されることを確認します。

Windows・Mac 別、エージェント別のインストール手順

出品者

AI Skill Market 公式

出品スキル 44 件

出品者のプロフィールとスキル一覧