File: get_bank_registry_hr.py

package info (click to toggle)
python-schwifty 2025.09.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,140 kB
  • sloc: python: 3,141; makefile: 209; sh: 9
file content (36 lines) | stat: -rw-r--r-- 881 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python
import json

import pandas


URL = "https://www.hnb.hr/documents/20182/121798/tf-pp-ds-vbb-xlsx-e-vbb.xlsx/"


def process():
    datas = pandas.read_excel(URL, skiprows=3, sheet_name=0, dtype=str)
    datas.fillna("", inplace=True)

    registry = []

    for row in datas.itertuples(index=False):
        _, name, bank_code, bic = row[:4]

        registry.append(
            {
                "country_code": "HR",
                "primary": True,
                "bic": str(bic).upper().replace(" ", ""),
                "bank_code": str(bank_code),
                "name": name,
                "short_name": name,
            }
        )

    print(f"Fetched {len(registry)} bank records")
    return registry


if __name__ == "__main__":
    with open("schwifty/bank_registry/generated_hr.json", "w") as fp:
        json.dump(process(), fp, indent=2)