Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Api changes (#10)
Browse files Browse the repository at this point in the history
* updated api for dates which will return last date currenies if it dont have values

* fixed currency issue for EUR
  • Loading branch information
nikhila05 authored Jun 8, 2018
1 parent 87bbf73 commit 914477e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 4 additions & 1 deletion scripts/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
cur.append(str(s.attributes['currency'].value))
rates.append(float(s.attributes['rate'].value))
except:
pass
try:
rates.remove(float(s.attributes['rate'].value))
except:
pass

for s in itemlist:
try:
Expand Down
13 changes: 6 additions & 7 deletions scripts/pusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@
'NZD', 'PHP', 'SGD', 'THB', 'ZAR']


def get_cleaned(line, codes):
def get_cleaned(line, codes, date):
i = 0
new_line = []
new_codes = []
del line[0]
if not date:
del line[0]
del line[-1]

for x in line:
if x != 'N/A':
new_codes.append(codes[i])
new_line.append(line[i])

i += 1

return new_line, new_codes


Expand Down Expand Up @@ -68,17 +67,17 @@ def dict_gen(row, currency, currency_codes, date):
x = 0
for row in spamreader:
date = row[0]
new_line, new_codes = get_cleaned(row, codes)
new_line, new_codes = get_cleaned(row, codes, '')

if x == 0:
x += 1
continue

# for EUR
eur_new_line, eur_new_codes = get_cleaned(row[:], codes[:])

eur_new_line, eur_new_codes = get_cleaned(row[:], codes[:], date)
eur_ = dict_gen(eur_new_line, currency="EUR", currency_codes=eur_new_codes, date=date)
print (json.dumps(eur_))

db_prices.insert_one(eur_)
# end EUR block

Expand Down

0 comments on commit 914477e

Please sign in to comment.