Skip to content

Instantly share code, notes, and snippets.

@zedshaw
Created October 10, 2015 17:22
Show Gist options
  • Save zedshaw/4b4586aa96b164e92eec to your computer and use it in GitHub Desktop.
Save zedshaw/4b4586aa96b164e92eec to your computer and use it in GitHub Desktop.
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