Created
January 9, 2017 22:57
-
-
Save efuquen/8d9bfe2dad3f146794ef759e24d1fd4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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