def find_possible_mistakes():
    fins = Program.objects.filter(types_of_assistance__financial=True).distinct().order_by('agency')
    csv_out = csv.writer(open('greater_than_50_pct_change.csv', 'w'))

    for f in fins:
        obs = ProgramObligation.objects.filter(type=1, program=f).order_by('fiscal_year')
        if obs:
            current = obs[0]
            for o in obs:
                if current == o: continue
                if not current.obligation: continue
                pct_change = float(o.obligation - current.obligation) / float(current.obligation)
                if pct_change < -.5 or pct_change > .5:
                    csv_out.writerow((o.program.program_number, o.program.program_title.encode('ascii', 'ignore') % "%s", current.fiscal_year, current.obligation, o.fiscal_year, o.obligation ))
                current = o
dataset/ETHPy150Open sunlightlabs/clearspending/failed_dollars.py/find_possible_mistakes/swapped operands of `%`