-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_bank_registry_be.py
38 lines (28 loc) · 1.02 KB
/
get_bank_registry_be.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
#!/usr/bin/env python
import json
import pandas
URL = "https://www.nbb.be/doc/be/be/protocol/r_fulllist_of_codes_current.xlsx"
def process():
registry = []
skip_names = ["NAV", "VRIJ", "NAP", "NYA", "VRIJ - LIBRE", "-"]
datas = pandas.read_excel(URL, skiprows=1, sheet_name=0, dtype=str)
datas.fillna("", inplace=True)
for row in datas.itertuples(index=False):
bank_code, bic, name, second_name = row[:4]
if str(bic).upper() in skip_names:
continue
registry.append(
{
"country_code": "BE",
"primary": True,
"bic": str(bic).upper().replace(" ", ""),
"bank_code": bank_code,
"name": name or second_name,
"short_name": name or second_name,
}
)
print(f"Fetched {len(registry)} bank records")
return registry
if __name__ == "__main__":
with open("registry/bank_registry/generated_be.json", "w") as fp:
json.dump(process(), fp, indent=2)