-
Notifications
You must be signed in to change notification settings - Fork 0
/
sme_dictionaries.py
57 lines (41 loc) · 1.54 KB
/
sme_dictionaries.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
# (c) 2021 - 2023 Open Risk (https://www.openriskmanagement.com)
import pprint
from xlrd import open_workbook
# open the workbook for reading
wb = open_workbook('SME Template-ECB Version 20 Taxonomy.xls')
# link to the currency table sheet
currency_sheet = wb.sheets()[3]
# initialize a dictionary
currency_table = {}
# read the data from the spreadsheet and add to the dictionary
for row in range(5,currency_sheet.nrows):
code = currency_sheet.cell(row,1).value
currency = currency_sheet.cell(row,2).value
currency_table[code] = currency
# link to the sector table sheet
sector_sheet = wb.sheets()[4]
# initialize a dictionary
sector_table = {}
# read the data from the spreadsheet and add to the dictionary
for row in range(5,sector_sheet.nrows):
code = sector_sheet.cell(row,1).value
sector = sector_sheet.cell(row,2).value
sector_table[code] = sector
# pp = pprint.PrettyPrinter(indent=4)
# pp.pprint(sector_table)
# link to the taxonomy table sheet
data_sheet = wb.sheets()[1]
# initialize a dictionary
data_table = {}
# read the data from the spreadsheet and add to the dictionary
for row in range(5,data_sheet.nrows):
field_id = data_sheet.cell(row,1).value
field_name = data_sheet.cell(row,4).value
# print(field_id, field_id[:2])
for element in ["AS","BS","CS"]:
if element == field_id[:2]:
# print(m, element, field_id[:2])
# print(element, field_id, field_name)
data_table[field_id] = field_name
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(data_table)