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
|
import json
import pandas
from schwifty import BIC
URL = "https://www.nbs.sk/_img/Documents/_PlatobneSystemy/EUROSIPS/Directory_IC_DPS_SR.csv"
def process():
datas = pandas.read_csv(URL, encoding="cp1250", delimiter=";")
datas = datas.dropna(how="all")
datas.fillna("", inplace=True)
registry = []
for row in datas.itertuples(index=False):
bank_code, name, bic = row[:3]
bic = str(bic).strip().upper()
if bic and not BIC(bic, allow_invalid=True).is_valid:
continue
registry.append(
{
"country_code": "SK",
"primary": True,
"bic": bic,
"bank_code": str(bank_code).strip().zfill(4),
"name": str(name).strip(),
"short_name": str(name).strip(),
}
)
print(f"Fetched {len(registry)} bank records")
return registry
if __name__ == "__main__":
with open("schwifty/bank_registry/generated_sk.json", "w") as fp:
json.dump(process(), fp, indent=2)
|