Created
October 10, 2015 17:29
-
-
Save zedshaw/2d03f7f123100430145d to your computer and use it in GitHub Desktop.
This file contains 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
import os | |
import csv | |
import sys | |
data = {} | |
completed = [] | |
base_url = "https://www.amazon.com/gp/your-account/order-history/ref=oh_aui_search?opt=ab&search=%s" | |
def amzn_url(order_id): | |
return base_url % order_id | |
def dump_and_open(found): | |
order_id, total, order_date = found['Order ID'], found['Total Charged'], found['Order Date'] | |
print "%s\t%s\t%s" % (order_id, total, order_date) | |
os.system('open "%s"' % found['URL']) | |
csv_file = sys.argv[1] | |
with open(csv_file) as csv_stream: | |
reader = csv.DictReader(csv_stream) | |
for row in reader: | |
row['URL'] = amzn_url(row['Order ID']) | |
total = row['Total Charged'][1:] | |
if total not in data: | |
data[total] = [row] | |
else: | |
data[total].append(row) | |
while True: | |
try: | |
amount = raw_input("Amount? ") | |
except EOFError: | |
print "Goodbye!" | |
break | |
try: | |
print "-------" | |
for found in data[amount]: | |
dump_and_open(found) | |
print "-------" | |
except KeyError: | |
print "Not Found!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment