Skip to content

Instantly share code, notes, and snippets.

@efuquen
Created January 9, 2017 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save efuquen/8d9bfe2dad3f146794ef759e24d1fd4c to your computer and use it in GitHub Desktop.
Save efuquen/8d9bfe2dad3f146794ef759e24d1fd4c to your computer and use it in GitHub Desktop.
mport csv
import locale
import sys
locale.setlocale(locale.LC_ALL, '')
csv_filepath = sys.argv[1]
winners = []
with open(csv_filepath, 'rb') as csvfile:
rows = csv.reader(csvfile)
is_header = True
for row in rows:
if is_header:
is_header = False
continue
title = row[2]
total_gross = row[5]
total_gross = int(total_gross[1:].replace(',', ''))
budget = row[6]
if not budget:
continue
budget = int(budget[1:].replace(',', '')) * 1000000
if total_gross > budget:
winners.append({
'title': title,
'total_gross': total_gross,
'budget': budget
})
for winner in winners:
title = winner['title']
total_gross = winner['total_gross']
budget = winner['budget']
profit = total_gross - budget
print '"{0}" Profit: {1}'.format(
title,
locale.currency(profit, grouping=True)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment