Python Knapsack Expense Balancer

Job ID: 39811152

Budget: $10 – $30 CAD

I have several CSV files containing raw financial transactions—positive amounts for income, negative for expenses. I need a Python-based knapsack solver that helps me decide which expenses to keep, postpone, or trim so the final balance is as close to zero (or positive) as possible.

How it should work
• Read one or more CSV files (standard comma-delimited, UTF-8).
• Detect the amount column automatically or from a simple command-line flag.
• Treat income rows as capacity and expense rows as items that “consume” that capacity.
• Run a 0/1 knapsack (or a suitable optimisation library such as pulp or OR-Tools) to pick the combination of expenses that fits the available income while maximising residual cash.
• Produce a clear console and CSV summary listing the chosen expenses, skipped expenses, total income, total spent, and net balance.

Deliverables
1. clean_balance.py (Python 3 script, no hard-coded paths)
2. README.md with setup and usage (pip install requirements, sample command)
3. A small sample CSV plus the script’s expected output for that file

Acceptance criteria
• Script runs with `python3 clean_balance.py sample.csv` and generates the summary without errors.
• Net balance reported matches independent verification within a cent.
• Code is commented clearly enough that I can tweak constraints and rerun on fresh CSVs.