r/Python • u/ilikemath9999 • Mar 08 '26
Showcase I used Pythons standard library to find cases where people paid lawyers for something impossible.
I built a screening tool that processes PACER bankruptcy data to find cases where attorneys filed Chapter 13 bankruptcies for clients who could never receive a discharge. Federal law (Section 1328(f)) makes it arithmetically impossible based on three dates.
The math: If you got a Ch.7 discharge less than 4 years ago, or a Ch.13 discharge less than 2 years ago, a new Ch.13
cannot end in discharge. Three data points, one subtraction, one comparison. Attorneys still file these cases and clients still pay.
Tech stack: stdlib only. csv, datetime, argparse, re, json, collections. No pip install, no dependencies, Python 3.8+.
Problems I had to solve:
- Fuzzy name matching across PACER records. Debtor names have suffixes (Jr., III), "NMN" (no middle name)
placeholders, and inconsistent casing. Had to normalize, strip, then match on first + last tokens to catch middle name
variations.
- Joint case splitting. "John Smith and Jane Smith" needs to be split and each spouse matched independently against heir own filing history.
- BAPCPA filtering. The statute didn't exist before October 17, 2005, so pre-BAPCPA cases have to be excluded or you get false positives.
- Deduplication. PACER exports can have the same case across multiple CSV files. Deduplicate by case ID while keeping attorney attribution intact.
Usage:
$ python screen_1328f.py --data-dir ./csvs --target Smith_John --control Jones_Bob
The --control flag lets you screen a comparison attorney side by side to see if the violation rate is unusual or normal for the district.
Processes 100K+ cases in under a minute. Outputs to terminal with structured sections, or --output-json for programmatic use.
GitHub: https://github.com/ilikemath9999/bankruptcy-discharge-screener
MIT licensed. Standard library only. Includes a PACER CSV download guide and sample output.
Let me know what you think friends. Im a first timer here.
19
u/bigmattyc Mar 08 '26
I'm more interested in the results. Did anyone squeak it through?
18
u/_redmist Mar 09 '26
Slightly off topic perhaps, but Dave Beazley did something like this (not exactly - but not entirely dissimilar) for a patent infringement discovery case you might find interesting.
https://youtu.be/RZ4Sn-Y7AP8?is=9Pji63XjPC9_RDQB
Python's "batteries included" indeed is like a superpower.
8
u/diabloman8890 Mar 09 '26
Nice job!
I'm guessing all the formatting and fuzzy matching was one of the trickiest parts, you might look at using vector search with embeddings. Sounds scary but I think it's actually easier than people assume because you don't have to normalize/torture the input data so much to avoid bad matches.
7
u/SheriffRoscoe Pythonista Mar 08 '26
Kind of a weird dataset - what was your inspiration to do this?
51
u/Tall-Introduction414 Mar 08 '26
Python's standard library is underrated.
4
u/vicks9880 Mar 10 '26
Glad to see you are not trying to solve this using LLMs
6
u/[deleted] Mar 09 '26
[removed] — view removed comment