from backend_app.models.currency import Currency import os import csv from .loadGeneric import LoadGeneric from decimal import Decimal class LoadCurrencies(LoadGeneric): def __init__(self, admin): self.admin = admin def load(self): tmp = os.path.join(os.path.realpath(__file__), "../../assets/currencies.csv") currencies_file_loc = os.path.abspath(tmp) with open(currencies_file_loc) as csvfile: reader = csv.reader(csvfile, quotechar='"') next(reader) for r in reader: currency = Currency( code=r[0], name=r[1], symbol="", one_EUR_in_this_currency=Decimal(r[2]), ) currency.save() self.add_info_and_save(currency, self.admin)