-
Notifications
You must be signed in to change notification settings - Fork 0
/
currency_compare_liniar.py
executable file
·58 lines (47 loc) · 1.57 KB
/
currency_compare_liniar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from openpyxl import Workbook
from helper_functions import *
from forex_python.converter import CurrencyRates
# preparation to work on the spreadsheat
workbook = Workbook()
sheet = workbook.active
def get_convresion_rate(crc_1, crc_2):
if crc_1 == crc_2:
return "-"
else:
try:
return round(CurrencyRates().get_rate(crc_1, crc_2), 4)
except:
return ""
# list of compared currencies
currency_list = ["USD",
"PLN",
"GBP",
"EUR",
"CHF",
"DKK",
"SEK",
"NOK",
"CZK",
"HUF",
"JPY"]
# current cell in which the data are put
column = 1
row = 1
# writing the header column and header row of names
for i in range(len(currency_list)):
localization = toExclNot(column + i + 1, row) # header row
sheet[localization] = currency_list[i]
localization = toExclNot(column, row + i + 1) # header column
sheet[localization] = currency_list[i]
# translation to the place where the data will be input
column = 2
row = 2
# actually writing the data into table
for next_column in range(len(currency_list)):
for next_row in range(len(currency_list)):
localization = toExclNot(column + next_column, row + next_row)
value = get_convresion_rate(currency_list[next_column],
currency_list[next_row])
#zaokraglenie
sheet[localization] = value
workbook.save(filename="currency_liniar_solution.xlsx")