Created
October 10, 2015 17:15
-
-
Save zedshaw/af64cf68f28082e6c2bb 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"' % amzn_url(found['Order ID'])) | |
csv_file = sys.argv[1] | |
with open(csv_file) as csv_stream: | |
reader = csv.DictReader(csv_stream) | |
for row in reader: | |
total = row['Total Charged'][1:] | |
data[total] = row | |
while True: | |
try: | |
amount = raw_input("Amount? ") | |
except EOFError: | |
print "Goodbye!" | |
break | |
try: | |
found = 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