def handle_noargs(self, **options): state_name = '' total_inserts = 0 total_updates = 0 wic = WicBenefitsStateRaw.objects.filter(type='total').order_by('state') total_raw = wic.count() for w in wic: if w.state != state_name: clean_state = clean_state_name(w.state) try: state_ref_current = State.objects.get(state_name__iexact=clean_state) except: print 'Skipping record. Unable to find state: %s' % clean_state continue state_name = w.state try: record = WicBenefitsState.objects.get(year = w.year, state = state_ref_current) record.amount = w.value record.save() total_updates = total_updates + 1 except: record = WicBenefitsState(year = w.year, state = state_ref_current, amount = w.value) record.save() total_inserts = total_inserts + 1 db.reset_queries() print 'total records from raw data = %s' % total_raw print 'total inserts = %s' % total_inserts print 'total_updates = %s' % total_updates
def handle_noargs(self, **options): state_name = "" total_inserts = 0 total_updates = 0 raw = SnapParticipationPeopleStateRaw.objects.all().order_by("state") total_raw = raw.count() for r in raw: if r.state != state_name: clean_state = clean_state_name(r.state) try: state_ref_current = State.objects.get(state_name__iexact=clean_state) except: print "Skipping record. Unable to find state: " + clean_state continue state_name = r.state try: record = SnapParticipationPeopleState.objects.get(year=r.year, state=state_ref_current) total_updates = total_updates + 1 except: record = SnapParticipationPeopleState(year=r.year, state=state_ref_current) total_inserts = total_inserts + 1 record.value = r.value record.save() db.reset_queries() print "SNAP Participation (state): total records from raw data = %s" % total_raw print "SNAP Participation (state): total inserts = %s" % total_inserts print "SNAP Participation (state): total updates = %s" % total_updates
def handle_noargs(self, **options): state_name = '' total_inserts = 0 total_updates = 0 raw = SchoolBreakfastParticipationStateRaw.objects.all().order_by('state') total_raw = raw.count() for r in raw: if r.state != state_name: clean_state = clean_state_name(r.state) try: state_ref_current = State.objects.get(state_name__iexact=clean_state) except: print 'Skipping record. Unable to find state: ' + clean_state continue state_name = r.state try: record = SchoolBreakfastParticipationState.objects.get(year=r.year,state=state_ref_current) total_updates = total_updates + 1 except: record = SchoolBreakfastParticipationState(year = r.year, state = state_ref_current) total_inserts = total_inserts + 1 record.value = r.value record.save() db.reset_queries() print 'School Breakfast Participation (state): total records from raw data = %s' % total_raw print 'School Breakfast Participation (state): total inserts = %s' % total_inserts print 'School Breakfast Participation (state): total updates = %s' % total_updates
def handle_noargs(self, **options): state_name = '' total_inserts = 0 total_updates = 0 raw = PeoplePovertyStateRaw.objects.all().order_by('state') total_raw = raw.count() for r in raw: if r.state != state_name: clean_state = clean_state_name(r.state) try: state_ref_current = State.objects.get( state_name__iexact=clean_state) except: print 'Skipping record. Unable to find state: ' + clean_state continue state_name = r.state try: record = PeoplePovertyState.objects.get( year=r.year, state=state_ref_current) total_updates = total_updates + 1 except: record = PeoplePovertyState(year=r.year, state=state_ref_current) total_inserts = total_inserts + 1 record.total_population = r.total_population record.value = r.value record.value_standard_error = r.value_standard_error record.percent = r.percent record.percent_standard_error = r.percent_standard_error record.save() db.reset_queries() print 'People In Poverty (state): total records from raw data = %s' % total_raw print 'People In Poverty (state): total inserts = %s' % total_inserts print 'People In Poverty (state): total updates = %s' % total_updates
def handle_noargs(self, **options): state_name = '' total_inserts = 0 total_updates = 0 raw = ChildrenPovertyStateRaw.objects.all().order_by('state') total_raw = raw.count() for r in raw: if r.state != state_name: clean_state = clean_state_name(r.state) try: state_ref_current = State.objects.get(state_name__iexact=clean_state) except: print 'Skipping record. Unable to find state: ' + clean_state continue state_name = r.state try: record = ChildrenPovertyState.objects.get(year=r.year,state=state_ref_current) total_updates = total_updates + 1 except: record = ChildrenPovertyState(year = r.year, state = state_ref_current) total_inserts = total_inserts + 1 record.children_total = r.children_total record.children_total_moe = r.children_total_moe record.children_poverty = r.children_poverty record.children_poverty_moe = r.children_poverty_moe record.children_poverty_percent = r.children_poverty_percent record.children_poverty_percent_moe = r.children_poverty_percent_moe record.save() db.reset_queries() print 'Children In Poverty (state): total records from raw data = %s' % total_raw print 'Children In Poverty (state): total inserts = %s' % total_inserts print 'Children In Poverty (state): total updates = %s' % total_updates
def handle_noargs(self, **options): state_name = '' total_inserts = 0 total_updates = 0 wic = WicBenefitsStateRaw.objects.filter( type='total').order_by('state') total_raw = wic.count() for w in wic: if w.state != state_name: clean_state = clean_state_name(w.state) try: state_ref_current = State.objects.get( state_name__iexact=clean_state) except: print 'Skipping record. Unable to find state: %s' % clean_state continue state_name = w.state try: record = WicBenefitsState.objects.get(year=w.year, state=state_ref_current) record.amount = w.value record.save() total_updates = total_updates + 1 except: record = WicBenefitsState(year=w.year, state=state_ref_current, amount=w.value) record.save() total_inserts = total_inserts + 1 db.reset_queries() print 'total records from raw data = %s' % total_raw print 'total inserts = %s' % total_inserts print 'total_updates = %s' % total_updates
def handle_noargs(self, **options): state_name = '' total_inserts = 0 total_updates = 0 person = TanfParticipationStateRaw.objects.all().order_by('state') total_raw = person.count() for t in person: if t.state != state_name: clean_state = clean_state_name(t.state) try: state_ref_current = State.objects.get(state_name__iexact=clean_state) except: print 'Skipping record. Unable to find state: ' + clean_state continue state_name = t.state try: record = TanfParticipationState.objects.get(year=t.year,state=state_ref_current) record.person = t.value total_updates = total_updates + 1 except: record = TanfParticipationState(year = t.year, state = state_ref_current, person = t.value) total_inserts = total_inserts + 1 record.save() db.reset_queries() print 'TANF person: total records from raw data = ' + str(total_raw) print 'TANF person: total inserts = ' + str(total_inserts) print 'TANF person: total updates = ' + str(total_updates) #update records with info re: # families state_name = '' total_inserts = 0 total_updates = 0 state_ref_current = '' family = TanfFamilyStateRaw.objects.all().order_by('state') total_raw = family.count() for t in family: if t.state != state_name: clean_state = clean_state_name(t.state) try: state_ref_current = State.objects.get(state_name=clean_state) except: print 'Skipping record. Unable to find state: ' + clean_state continue state_name = t.state try: record = TanfParticipationState.objects.get(year=t.year,state=state_ref_current) record.family = t.value total_updates = total_updates + 1 except: record = TanfParticipationState(year = t.year, state = state_ref_current, family = t.value) total_inserts = total_inserts + 1 record.save() db.reset_queries() print 'TANF family: total records from raw data = ' + str(total_raw) print 'TANF family: total inserts = ' + str(total_inserts) print 'TANF family: total updates = ' + str(total_updates)
def handle_noargs(self, **options): state_name = '' total_inserts = 0 total_updates = 0 person = TanfParticipationStateRaw.objects.all().order_by('state') total_raw = person.count() for t in person: if t.state != state_name: clean_state = clean_state_name(t.state) try: state_ref_current = State.objects.get( state_name__iexact=clean_state) except: print 'Skipping record. Unable to find state: ' + clean_state continue state_name = t.state try: record = TanfParticipationState.objects.get( year=t.year, state=state_ref_current) record.person = t.value total_updates = total_updates + 1 except: record = TanfParticipationState(year=t.year, state=state_ref_current, person=t.value) total_inserts = total_inserts + 1 record.save() db.reset_queries() print 'TANF person: total records from raw data = ' + str(total_raw) print 'TANF person: total inserts = ' + str(total_inserts) print 'TANF person: total updates = ' + str(total_updates) #update records with info re: # families state_name = '' total_inserts = 0 total_updates = 0 state_ref_current = '' family = TanfFamilyStateRaw.objects.all().order_by('state') total_raw = family.count() for t in family: if t.state != state_name: clean_state = clean_state_name(t.state) try: state_ref_current = State.objects.get( state_name=clean_state) except: print 'Skipping record. Unable to find state: ' + clean_state continue state_name = t.state try: record = TanfParticipationState.objects.get( year=t.year, state=state_ref_current) record.family = t.value total_updates = total_updates + 1 except: record = TanfParticipationState(year=t.year, state=state_ref_current, family=t.value) total_inserts = total_inserts + 1 record.save() db.reset_queries() print 'TANF family: total records from raw data = ' + str(total_raw) print 'TANF family: total inserts = ' + str(total_inserts) print 'TANF family: total updates = ' + str(total_updates)
def handle_noargs(self, **options): state_name = '' total_inserts = 0 total_updates = 0 raw = HealthInsuranceStateRaw.objects.all().order_by('state') total_raw = raw.count() for r in raw: if r.state != state_name: clean_state = clean_state_name(r.state) try: state_ref_current = State.objects.get(state_name=clean_state) except: print 'Skipping record. Unable to find state: ' + clean_state continue state_name = r.state try: record = HealthInsuranceState.objects.get(year=r.year,state=state_ref_current) total_updates = total_updates + 1 except: record = HealthInsuranceState(year = r.year, state = state_ref_current) total_inserts = total_inserts + 1 record.pop = r.pop record.pop_moe = r.pop_moe record.pop_no_ins = (r.pop_under_18_no_ins + r.pop_18_34_no_ins + r.pop_35_64_no_ins + r.pop_over_64_no_ins) record.pop_no_ins_percent = format( record.pop_no_ins / Decimal(record.pop) * 100, '.1f') record.pop_ins = record.pop - record.pop_no_ins record.pop_ins_percent = format( record.pop_ins / Decimal(record.pop) * 100, '.1f') record.pop_under_18 = r.pop_under_18 record.pop_under_18_moe = r.pop_under_18_moe record.pop_under_18_private = r.pop_under_18_private record.pop_under_18_private_moe = r.pop_under_18_private_moe record.pop_under_18_public = r.pop_under_18_public record.pop_under_18_public_moe = r.pop_under_18_public_moe record.pop_under_18_private_public = r.pop_under_18_private_public record.pop_under_18_private_public_moe = r.pop_under_18_private_public_moe record.pop_under_18_no_ins = r.pop_under_18_no_ins record.pop_under_18_no_ins_moe = r.pop_under_18_no_ins_moe record.pop_under_18_no_ins_percent = format( record.pop_under_18_no_ins / Decimal(record.pop_under_18) * 100, '.1f') record.pop_under_18_ins = record.pop_under_18 - record.pop_under_18_no_ins record.pop_under_18_ins_percent = format( record.pop_under_18_ins / Decimal(record.pop_under_18) * 100, '.1f') record.pop_18_34 = r.pop_18_34 record.pop_18_34_moe = r.pop_18_34_moe record.pop_18_34_private = r.pop_18_34_private record.pop_18_34_private_moe = r.pop_18_34_private_moe record.pop_18_34_public = r.pop_18_34_public record.pop_18_34_public_moe = r.pop_18_34_public_moe record.pop_18_34_private_public = r.pop_18_34_private_public record.pop_18_34_private_public_moe = r.pop_18_34_private_public_moe record.pop_18_34_no_ins = r.pop_18_34_no_ins record.pop_18_34_no_ins_moe = r.pop_18_34_no_ins_moe record.pop_18_34_no_ins_percent = format( record.pop_18_34_no_ins / Decimal(record.pop_18_34) * 100, '.1f') record.pop_18_34_ins = record.pop_18_34 - record.pop_18_34_no_ins record.pop_18_34_ins_percent = format( record.pop_18_34_ins / Decimal(record.pop_18_34) * 100, '.1f') record.pop_35_64 = r.pop_35_64 record.pop_35_64_moe = r.pop_35_64_moe record.pop_35_64_private = r.pop_35_64_private record.pop_35_64_private_moe = r.pop_35_64_private_moe record.pop_35_64_public = r.pop_35_64_public record.pop_35_64_public_moe = r.pop_35_64_public_moe record.pop_35_64_private_public = r.pop_35_64_private_public record.pop_35_64_private_public_moe = r.pop_35_64_private_public_moe record.pop_35_64_no_ins = r.pop_35_64_no_ins record.pop_35_64_no_ins_moe = r.pop_35_64_no_ins_moe record.pop_35_64_no_ins_percent = format( record.pop_35_64_no_ins / Decimal(record.pop_35_64) * 100, '.1f') record.pop_35_64_ins = record.pop_35_64 - record.pop_35_64_no_ins record.pop_35_64_ins_percent = format( record.pop_35_64_ins / Decimal(record.pop_35_64) * 100, '.1f') record.pop_18_64 = record.pop_18_34 + record.pop_35_64 record.pop_18_64_private = (record.pop_18_34_private + record.pop_35_64_private) record.pop_18_64_public = (record.pop_18_34_public + record.pop_35_64_public) record.pop_18_64_private_public = (record.pop_18_34_private_public + record.pop_35_64_private_public) record.pop_18_64_no_ins = (record.pop_18_34_no_ins + record.pop_35_64_no_ins) record.pop_18_64_no_ins_percent = format( record.pop_18_64_no_ins / Decimal(record.pop_18_64) * 100, '.1f') record.pop_18_64_ins = record.pop_18_64 - record.pop_18_64_no_ins record.pop_18_64_ins_percent = format( record.pop_18_64_ins / Decimal(record.pop_18_64) * 100, '.1f') record.pop_over_64 = r.pop_over_64 record.pop_over_64_moe = r.pop_over_64_moe record.pop_over_64_private = r.pop_over_64_private record.pop_over_64_private_moe = r.pop_over_64_private_moe record.pop_over_64_public = r.pop_over_64_public record.pop_over_64_public_moe = r.pop_over_64_public_moe record.pop_over_64_private_public = r.pop_over_64_private_public record.pop_over_64_private_public_moe = r.pop_over_64_private_public_moe record.pop_over_64_no_ins = r.pop_over_64_no_ins record.pop_over_64_no_ins_moe = r.pop_over_64_no_ins_moe record.pop_over_64_no_ins_percent = format( record.pop_over_64_no_ins / Decimal(record.pop_over_64) * 100, '.1f') record.pop_over_64_ins = record.pop_over_64 - record.pop_over_64_no_ins record.pop_over_64_ins_percent = format( record.pop_over_64_ins / Decimal(record.pop_over_64) * 100, '.1f') record.save() db.reset_queries() print 'Health Insurance (state): total records from raw data = %s' % total_raw print 'Health Insurance (state): total inserts = %s' % total_inserts print 'Health Insurance (state): total updates = %s' % total_updates