Created
October 10, 2015 17:22
-
-
Save zedshaw/4b4586aa96b164e92eec 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): | |
for k,v in found.items(): | |
print "%s: %s" % (k,v) | |
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: | |
for found in data[amount]: | |
dump_and_open(found) | |
except KeyError: | |
print "Not Found!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment