Back to prompts
Code25.11.2026
Write a Python Script That Splits Shared Holiday Costs and Shows Who Owes Whom
#python#csv#split expenses#holiday costs#group gift#friendsgiving#automation
You are a careful Python developer who writes small, readable scripts for everyday personal automation. Over the holidays my friends and family share a lot of costs: a Friendsgiving dinner, a cabin or rental, gas for a road trip, and group gifts, and different people pay at different times. I want a script that reads a simple list of who paid what and who shared each cost, then shows each person's balance and the fewest simple payments needed to settle up. Write the script and explain how to run it. Use only the Python standard library unless I say otherwise, and only the details I give you. Do not assume amounts, people, currencies, or splitting rules I did not provide. If something is missing, mark it [NEEDS INPUT]. How I keep the list of shared costs (CSV file, spreadsheet exported to CSV) and its file name: [FILE] The columns I have or can add (for example date, description, paid by, amount, shared by, and split type such as equal, shares, or exact amounts): [COLUMNS] The people in the group and the exact names we use in the list: [PEOPLE] How we split costs (always equal, by shares such as a couple counting as 2, or exact amounts per person for some items): [SPLIT RULES] Currency, and whether some costs were paid in a different currency: [CURRENCY] My operating system and Python version, if known: [ENVIRONMENT] How I want to share the result (printed in the terminal, a CSV, or a short text I can paste into a group chat): [OUTPUT] Requirements: 1. Confirm the expected CSV layout based on [COLUMNS] and [SPLIT RULES], and show a 6 row sample file with fictional people and costs, including one exact split and one shares split, so I can copy the format. 2. Read the CSV with the csv module, handle a header row, trim spaces, accept a list of people in the shared by column separated by semicolons, and accept amounts with or without a currency symbol. 3. Validate each row and report problems clearly with the row number, such as a name not in [PEOPLE], an exact split that does not add up to the amount, or a missing payer, without crashing the whole run. 4. Use decimal.Decimal for money, not float. When an amount cannot be split evenly to the cent, explain how the leftover cents are assigned so totals always match exactly. 5. Calculate for each person: total paid, total share of costs, and net balance, and check that all balances add up to zero. 6. Produce a settle up list with the fewest simple payments, such as "Alex pays Sam 24.50", using a clear greedy method, and explain in two sentences how it works. 7. If [CURRENCY] says some costs are in another currency, do not convert them using an invented rate. List those rows separately as [NEEDS INPUT] or ask me to add a converted amount column. 8. Produce the output chosen in [OUTPUT], including a short friendly text version for a group chat that lists only the payments, with no blame wording. 9. Keep the script in one file, under about 170 lines, with short comments, a main function, and argparse for the file path and optional output file. 10. Give step by step instructions to run it on [ENVIRONMENT], and 3 quick tests with the sample file, including one bad row, with the expected results. Deliverables: 1. Expected CSV layout and sample file 2. Complete Python script 3. Explanation of the split and settle up rules 4. How to run it 5. 3 quick tests with expected results 6. Group chat summary example
How to use this prompt
- 1Copy the prompt using the button above.
- 2Open your AI tool (ChatGPT, Claude, Midjourney, etc.)
- 3Paste and customize any variables in the prompt.
- 4Generate your result.
Tip
Fill every placeholder before you run the prompt. Keep one clear goal per run, then refine with a follow-up if needed.
When to use this prompt
- •Good for first drafts in Code
- •Keep variables filled so the model has enough context
- •Review AI output before sending or publishing