def load_monthly(self, filename): with open(filename, 'rU') as csvfile: csvreader = csv.reader(csvfile, delimiter=',', quotechar='"') # Delete all items in tables Monthly.objects.all().delete() # Remove the first line which is the header line csvreader.next() for row in csvreader: insurer, min_ltv, max_ltv, min_fico, max_fico, loan_term, pmt_type, min_loan_amt, max_loan_amt, premium = row m = Monthly() m.insurer = insurer.strip().upper() m.min_ltv = Decimal(min_ltv) m.max_ltv = Decimal(max_ltv) m.min_fico = int(min_fico) m.max_fico = int(max_fico) m.loan_term = int(loan_term) m.pmt_type = pmt_type.strip().upper() m.min_loan_amt = Decimal(min_loan_amt) m.max_loan_amt = Decimal(max_loan_amt) m.premium = Decimal(premium) m.save() self.stdout.write('\nSuccessfully loaded data from %s\n\n' % filename)
def load_monthly(self, filename): with open(filename, 'rU') as csvfile: csvreader = csv.reader(csvfile, delimiter=',', quotechar='"') # Delete all items in tables Monthly.objects.all().delete() # Remove the first line which is the header line csvreader.next() for row in csvreader: insurer, min_ltv, max_ltv, min_fico, max_fico, loan_term, pmt_type, min_loan_amt, max_loan_amt, premium = row m = Monthly() m.insurer = insurer.strip().upper() m.min_ltv = Decimal(min_ltv) m.max_ltv = Decimal(max_ltv) m.min_fico = int(min_fico) m.max_fico = int(max_fico) m.loan_term = int(loan_term) m.pmt_type = pmt_type.strip().upper() m.min_loan_amt = Decimal(min_loan_amt) m.max_loan_amt = Decimal(max_loan_amt) m.premium = Decimal(premium) m.save() self.stdout.write('\nSuccessfully loaded data from %s\n\n' % filename)
def populate_db(self): """ Prepopulate DB with dummy data. """ m_ins1_1 = Monthly(insurer='INS1',min_ltv=Decimal("30.001"),max_ltv=Decimal("70"),min_fico=700,max_fico=740,loan_term=30,pmt_type='FIXED',min_loan_amt=Decimal("400000"),max_loan_amt=Decimal("1000000"),premium=Decimal("1.4")) m_ins1_1.save() m_ins2_1 = Monthly(insurer='INS2',min_ltv=Decimal("30.001"),max_ltv=Decimal("70"),min_fico=700,max_fico=740,loan_term=30,pmt_type='FIXED',min_loan_amt=Decimal("400000"),max_loan_amt=Decimal("1000000"),premium=Decimal("1.6")) m_ins2_1.save() m_ins1_2 = Monthly(insurer='INS1',min_ltv=Decimal("20.001"),max_ltv=Decimal("30"),min_fico=700,max_fico=740,loan_term=30,pmt_type='FIXED',min_loan_amt=Decimal("400000"),max_loan_amt=Decimal("1000000"),premium=Decimal("0.523")) m_ins1_2.save() m_ins2_2 = Monthly(insurer='INS2',min_ltv=Decimal("20.001"),max_ltv=Decimal("30"),min_fico=700,max_fico=740,loan_term=30,pmt_type='FIXED',min_loan_amt=Decimal("400000"),max_loan_amt=Decimal("1000000"),premium=Decimal("0.642")) m_ins2_2.save() m_fha = Monthly(insurer='FHA',min_ltv=Decimal("20.001"),max_ltv=Decimal("70"),min_fico=700,max_fico=740,loan_term=30,pmt_type='FIXED',min_loan_amt=Decimal("400000"),max_loan_amt=Decimal("1000000"),premium=Decimal("0.85")) m_fha.save() u_fha = Upfront(loan_type='FHA',min_ltv=Decimal("0"), max_ltv=Decimal("80"),premium=Decimal("3.75")) u_fha.save() u_va_disabled = Upfront(loan_type='VA',va_status='DISABLED',min_ltv=Decimal("0"), max_ltv=Decimal("80"),premium=Decimal("1.5")) u_va_disabled.save() u_va_regular_y = Upfront(loan_type='VA',va_status='REGULAR',va_first_use='Y',min_ltv=Decimal("0"),max_ltv=Decimal("80"),premium=Decimal("2.0")) u_va_regular_y.save()
def populate_db(self): """ Prepopulate DB with dummy data. """ m_ins1_1 = Monthly(insurer='INS1', min_ltv=Decimal("30.001"), max_ltv=Decimal("70"), min_fico=700, max_fico=740, loan_term=30, pmt_type='FIXED', min_loan_amt=Decimal("400000"), max_loan_amt=Decimal("1000000"), premium=Decimal("1.4")) m_ins1_1.save() m_ins2_1 = Monthly(insurer='INS2', min_ltv=Decimal("30.001"), max_ltv=Decimal("70"), min_fico=700, max_fico=740, loan_term=30, pmt_type='FIXED', min_loan_amt=Decimal("400000"), max_loan_amt=Decimal("1000000"), premium=Decimal("1.6")) m_ins2_1.save() m_ins1_2 = Monthly(insurer='INS1', min_ltv=Decimal("20.001"), max_ltv=Decimal("30"), min_fico=700, max_fico=740, loan_term=30, pmt_type='FIXED', min_loan_amt=Decimal("400000"), max_loan_amt=Decimal("1000000"), premium=Decimal("0.523")) m_ins1_2.save() m_ins2_2 = Monthly(insurer='INS2', min_ltv=Decimal("20.001"), max_ltv=Decimal("30"), min_fico=700, max_fico=740, loan_term=30, pmt_type='FIXED', min_loan_amt=Decimal("400000"), max_loan_amt=Decimal("1000000"), premium=Decimal("0.642")) m_ins2_2.save() m_fha = Monthly(insurer='FHA', min_ltv=Decimal("20.001"), max_ltv=Decimal("70"), min_fico=700, max_fico=740, loan_term=30, pmt_type='FIXED', min_loan_amt=Decimal("400000"), max_loan_amt=Decimal("1000000"), premium=Decimal("0.85")) m_fha.save() u_fha = Upfront(loan_type='FHA', min_ltv=Decimal("0"), max_ltv=Decimal("80"), premium=Decimal("3.75")) u_fha.save() u_va_disabled = Upfront(loan_type='VA', va_status='DISABLED', min_ltv=Decimal("0"), max_ltv=Decimal("80"), premium=Decimal("1.5")) u_va_disabled.save() u_va_regular_y = Upfront(loan_type='VA', va_status='REGULAR', va_first_use='Y', min_ltv=Decimal("0"), max_ltv=Decimal("80"), premium=Decimal("2.0")) u_va_regular_y.save()