File: get_bank_registry_no.py

package info (click to toggle)
python-schwifty 2024.09.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,072 kB
  • sloc: python: 3,057; makefile: 209; sh: 9
file content (30 lines) | stat: -rw-r--r-- 706 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
#!/usr/bin/env python
import json

import pandas


URL = "https://www.bits.no/document/iban/"


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

    return [
        {
            "country_code": "NO",
            "primary": True,
            "bic": str(bic).upper().strip(),
            "bank_code": bank_code,
            "name": name,
            "short_name": name,
        }
        for bank_code, bic, name in list(datas.itertuples(index=False))[1:]
        if bank_code != ""
    ]


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