@@ -0,0 +1,2096 @@
+# -*- coding: UTF-8 -*-%0Afrom __future__ import unicode_literals%0A%0Afrom django.core.management.base import BaseCommand%0A%0Afrom tx_highered.models import Institution%0A%0A%0Aclass Command(BaseCommand):%0A    help = (%0A        'Create a report card of our data quality. Run it through '%0A        'http://setosa.io/csv-fingerprint/ for a quick visualization.'%0A    )%0A%0A    def handle(self, *args, **options):%0A%0A        def latest_year(institution, relation):%0A            %22%22%22Latest year institution has data, returns year or ''.%22%22%22%0A            try:%0A                return getattr(institution, relation).all().order_by('-year')%5B0%5D.year%0A            except IndexError:%0A                return ''%0A%0A        header = %5B'name'%5D%0A        print ','.join(header)%0A        for institution in Institution.objects.published():%0A            row = %5Binstitution.slug%5D%0A            header.append('Admissions IPEDS')%0A            row.append(latest_year(institution, 'admissions'))%0A            header.append('Admissions THECB')%0A            if institution.is_private:%0A                row.append('NA')%0A            else:%0A                row.append(latest_year(institution, 'publicadmissions'))%0A%0A            header.append('Test Scores')%0A            row.append(latest_year(institution, 'testscores'))%0A%0A            header.append('Enrollment IPEDS')%0A            row.append(latest_year(institution, 'enrollment'))%0A            header.append('Enrollment THECB')%0A            if institution.is_private:%0A                row.append('NA')%0A            else:%0A                row.append(latest_year(institution, 'publicenrollment'))%0A%0A            header.append('Price Trends')%0A            row.append(latest_year(institution, 'pricetrends'))%0A%0A            header.append('Graduation IPEDS')%0A            row.append(latest_year(institution, 'graduationrates'))%0A            header.append('Graduation THECB')%0A            if institution.is_private:%0A                row.append('NA')%0A            else:%0A                row.append(latest_year(institution, 'publicgraduationrates'))%0A%0A            print ','.join(map(unicode, row))%0A%0A        # print header%0A        # print rows%0A

add command to quickly evaluate data quality