Hacking my phone bill
September 23, 2010, 6:54 pm
Because I am a huge nerd, I sat down for five minutes in the local Telstra shop and wrote a python script to analyse an old mobile bill to work out what cap plan I should get.
f = open ("bill.txt", "r")
lines = f.readlines()
# flagfall in cents
flagfall = 37
# cost per thirty seconds in cents
perthirty = 40
#total in cents
total = 0
#total seconds logged
total_seconds = 0
#calls made
calls = 0
for line in lines:
vec = line.split(":")
if (len(vec) != 3):
continue
print vec
seconds = int(vec[0]) * 60
seconds += int(vec[1])
total += flagfall
total += perthirty * (seconds / 30.0)
total_seconds += seconds
calls += 1
# number of sms that month
sms = 74
sms_cost = 74 * 25
total += sms_cost
print "$" + str(total/100.0) + " for " + str(calls) + " calls, " + str(total_seconds/60) + " mins, " + str(total_seconds%60) + " secs"
f.close()
It assumes a bill.txt file with the following format:
0:30:00
0:30:00
0:30:00
0:30:00
0:30:00
0:30:00
Permalink - Tags: Development