コード例 #1
0
 def get_collegeslycees(self):
     c = self.cached_request(COLLEGESLYCEES_URL, 'collegeslycess.json')
     for row in c:
         row = row['fields']
         uai = row['identifiant_de_l_etablissement']
         if not row.get('nom_etablissement'):
             self.uai_to_delete.add(uai)
             continue
         if any(row.get(t, False) for t in ('ecole_maternelle', 'ecole_primaire')):
             self.uai_to_delete.add(uai)
             continue
         if any(t in row['type_etablissement'] for t in ('orientation', 'primaire', 'maternelle')):
             self.uai_to_delete.add(uai)
             continue
         address = ('adresse_%d' % i for i in (1, 2))
         address = ' '.join(row[col] for col in address if col in row).strip()
         school = School(uai=uai,
                         name=row['nom_etablissement'] or '',
                         address=address,
                         postal_code=row['code_postal'] or '',
                         city=row['nom_commune'] or '',
                         country='France',
                         type=row['type_etablissement'] or '',
                         imported=True, approved=True)
         if 'position' in row:
             school.lat = row['position'][0]
             school.lng = row['position'][1]
         yield school
コード例 #2
0
    def test_create_school(self):
        school = School(name="The great School of Test",
                        short_name="test school",
                        description="<p>Some rich text description?</p>")
        school.save()
        self.assertEqual('the-great-school-of-test', school.slug)

        self.assertEqual(School.objects.get(slug='the-great-school-of-test'),
                         school)
コード例 #3
0
ファイル: tests.py プロジェクト: Acidburn0zzz/lernanta
    def test_create_school(self):
        school = School(
            name = "The great School of Test",
            short_name = "test school",
            description = "<p>Some rich text description?</p>"
        )
        school.save()
        self.assertEqual('the-great-school-of-test', school.slug)

        self.assertEqual(
            School.objects.get(slug='the-great-school-of-test'),
            school
        )
コード例 #4
0
def transfer(request):
    for each in school_list.school_choices:
        name = each[0]
        list_ = name.split('г.')
        v_name = list_[0]
        v_name = v_name.strip()
        if len(list_) >1:         
            city = list_[1]
            city = city.strip()
        else:
            city = "Город N"
        country = 'Россия'
        school = School(name=v_name, country=country, city = city)
        school.save()
    return HttpResponse('vasa')
コード例 #5
0
 def get_superieur(self):
     c = self.cached_request(SUPERIEUR_URL, 'superieur.json')
     for row in c:
         uai = row['code_uai']
         if not row['nom']:
             self.uai_to_delete.add(uai)
             continue
         school = School(uai=uai,
                         name=row['nom'],
                         acronym=row['sigle'] or '',
                         academy=row['academie'] or '',
                         address=row['adresse'] or '',
                         postal_code=row['cp'] or '',
                         city=row['commune'] or '',
                         country='France',
                         type=row["type_detablissement"] or '',
                         imported=True, approved=True)
         try:
             school.lat = row['latitude_y']
             school.lng = row['longitude_x']
         except KeyError:
             pass
         yield school
コード例 #6
0
def cb(count, ds):
    school = School()

    school.name = ds["name"]
    school.gsid = ds["universal-id"]
    school.city = ds["city"]
    if len(ds["zip"]) > 6:
        ds["zip"] = ds["zip"][:6]
    school.zip = ds["zip"]
    school.state = ds["state"]
    school.lat = ds["lat"]
    school.lon = ds["lon"]

    if len(ds["subtype"]) > 50:
        ds["subtype"] = 'special'
    school.type = ds["subtype"]

    sql = 'insert into schools_school values ("' + ds[
        "universal-id"] + '","' + ds["name"] + '","' + ds[
            "subtype"] + '","' + ds["city"] + '","' + ds["state"] + '","' + ds[
                "zip"] + '","' + ds["lat"] + '","' + ds["lon"] + '",0);'

    print sql
コード例 #7
0
def add(request):
    if request.method == "POST":
        form = request.POST
        # print(form) # for testing
        school = School()
        school.name = form['name']
        school.code = form['code']
        school.address = form['address']
        school.no_of_students = form['no_of_students']
        school.save()

        return redirect('schools:school_detail', school.pk)

    context = {}

    return render(request, 'schools/add.html', context)
コード例 #8
0
ファイル: parse_and_gen_sql.py プロジェクト: braskin/pd
def cb(count,ds):
  school = School()

  school.name = ds["name"]
  school.gsid = ds["universal-id"]
  school.city = ds["city"]
  if len(ds["zip"]) > 6:
    ds["zip"] = ds["zip"][:6]
  school.zip = ds["zip"]
  school.state = ds["state"]
  school.lat = ds["lat"]
  school.lon = ds["lon"]

  if len(ds["subtype"]) > 50:
    ds["subtype"] = 'special'
  school.type = ds["subtype"]

  sql =   'insert into schools_school values ("'+ds["universal-id"]+'","'+ ds["name"] + '","' + ds["subtype"] + '","' + ds["city"] + '","' + ds["state"] + '","' + ds["zip"] + '","' + ds["lat"] + '","' + ds["lon"] + '",0);'

  print sql
コード例 #9
0
def create_default_school(app, created_models, verbosity, db, **kwargs):
    # Only create the default schools in databases where Django created the table
    if School in created_models and router.allow_syncdb(db, School):
        if verbosity >= 2:
            print("Creating the default School object")
        School(pk=1,
               name="Default School",
               short_name="Default",
               hostname="localhost").save(using=db)

        # We set an explicit pk instead of relying on auto-incrementation,
        # so we need to reset the database sequence. See #17415.
        sequence_sql = connections[db].ops.sequence_reset_sql(
            no_style(), [School])
        if sequence_sql:
            if verbosity >= 2:
                print("Resetting sequence")
            cursor = connections[db].cursor()
            for command in sequence_sql:
                cursor.execute(command)

    School.objects.clear_cache()
コード例 #10
0
ファイル: importdata1.py プロジェクト: klpdotorg/dubdubdub
    def handle(self, *args, **options):
        filename, self.image_location = args
        file = open(filename, 'r')
        self.data = csv.DictReader(file)
        dev_user = User.objects.get(email='*****@*****.**')

        for d in self.data:
            # ,Unnamed: 0_x,S No_x,Date,Block,Cluster,School Name_spotways,
            # KLP ID,Address,PIN Code,PlayGround?,Fence?,Landmark #1,
            # Landmark #2,Route to School,Bus Details,
            # LAT_spotways,LONG_spotways,Unnamed: 0_y,S No_y,klp_district,
            # klp_block,klp_cluster,dise_code,School Name_ems,category,
            # management,LAT_ems,LONG_ems,institution_gender,hierarchy,moi
            klpid = d['KLP ID']
            address = d['Address']
            landmark = d['Landmark #1']
            bus = d['Bus Details']
            pincode = d['PIN Code']
            lat = d['LAT_spotways']
            lon = d['LONG_spotways']
            coordinates = 'POINT ('+lon+' '+lat+')'

            connection, cursor = self.connectKlpCoord()

            if klpid.startswith('5'):
                continue

            print '='*20

            try:
                school = School.objects.get(id=klpid)
            except School.DoesNotExist:
                # School doesn't exist
                print 'Creating new school with id: %s' % klpid
                print d
                school = School(
                    id=klpid,
                    name=d.get('School Name_ems'),
                    cat=d.get('category'),
                    sex=d.get('institution_gender', 'co-ed'),
                    moi=d.get('moi', 'kannada') or 'kannada',
                    mgmt=d.get('management', 'ed'),
                    status=2
                )
                school.admin3 = self.get_or_create_admin3(d)

            if address:
                if school.address and (not school.address == address):
                    school_address = school.address
                    school_address.address = address
                else:
                    print 'Creating new address for klpid: %s' % klpid
                    school_address = Address.objects.create(
                        address=address
                    )
                    school.address = school_address

            # Update address details.
            if landmark:
                school_address.landmark = landmark
            if bus:
                school_address.bus = bus
            if pincode:
                school_address.pincode = pincode

            school_address.save()
            school.save()

            # Story
            story = {
                'date': d['Date'],
                'user': dev_user,
                'email': '*****@*****.**',
                'name': 'Team KLP',
                'school': school
            }

            self.createStory(story, klpid, d)

            if lat.strip() and lon.strip():
                self.updateCoord(cursor, klpid, coordinates)

            cursor.close()
            connection.commit()
            connection.close()
コード例 #11
0
def cb(count, ds):
    school = None
    try:
        school = School.objects.get(gsid=ds["universal-id"])
    except:
        school = School()

#  print "called for num:" + str(count) + "val: " + str(ds)

    school.name = ds["name"]
    school.gsid = ds["universal-id"]
    school.city = ds["city"]
    if len(ds["zip"]) > 6:
        ds["zip"] = ds["zip"][:6]
    school.zip = ds["zip"]
    school.state = ds["state"]
    school.lat = ds["lat"]
    school.lon = ds["lon"]
    school.gsurl = ds["url"]

    if len(ds["street"]) > 50:
        ds["street"] = ds["street"][:49]

    school.street = ds["street"]

    if len(ds["level"]) > 20:
        ds["level"] = ds["level"][:19]

    school.level = ds["level"]

    if len(ds["phone"]) > 20:
        ds["phone"] = ds["phone"][:19]

    school.phone = ds["phone"]

    if len(ds["subtype"]) > 50:
        ds["subtype"] = 'special'
    school.type = ds["subtype"]

    if len(ds["district-name"]) > 50:
        ds["district-name"] = ds["district-name"][:49]

    school.district_name = ds["district-name"]

    #  try:
    print school.gsurl
    school.save()
コード例 #12
0
def import_secondary_schools():
    period = datetime.datetime(day=31, month=12, year=2007)
    filename = "%s/documentation/data/2007/secondary.csv" % settings.BASE_DIR
    n = 1
    with open(filename, "rb") as ifile:
        reader = csv.reader(ifile)
        for row in reader:
            if n > 1:
                school = School()
                school.code = row[0].strip()
                school.name = row[1].strip()
                school.address = row[2].strip()
                school.level = School.SECONDARY
                school.ownership = get_ownership(row[3].strip())
                school.sponsor = get_sponsor(row[4].strip())
                school.student_gender = get_student_gender(row[5].strip())
                school.school_type = get_school_type(row[6].strip())
                school.student_needs = get_student_needs(row[6].strip())

                # location
                province, created = Province.objects.get_or_create(name=row[23].strip().upper())
                school.province = province
                county, created = County.objects.get_or_create(name=row[24].strip().upper())
                school.county = county
                if row[30]:
                    constituency = Constituency.objects.filter(name=row[30].strip().upper()).first()
                    if not constituency:
                        constituency, created = Constituency.objects.get_or_create(name=row[30].strip().upper(), county=county)
                    school.constituency = constituency
                if row[25]:
                    district = District.objects.filter(name=row[25].strip().upper()).first()
                    if not district:
                        district, created = District.objects.get_or_create(name=row[25].strip().upper(), province=province)
                    school.district = district
                if row[26]:
                    division, created = Division.objects.get_or_create(name=row[26].strip().upper(), district=district)
                    school.division = division
                if row[27]:
                    location, created = Location.objects.get_or_create(name=row[27].strip().upper(), division=division)
                    school.location = location
                if row[28]:
                    sub_location, created = SubLocation.objects.get_or_create(name=row[28].strip().upper(), location=location)
                    school.sub_location = sub_location
                if row[29]:
                    school_zone, created = SchoolZone.objects.get_or_create(name=row[29].strip().upper(), county=county)
                    school.school_zone = school_zone

                if row[31]:
                    coord = row[31].split(",")
                    x = float(coord[0][1:])
                    y = float(coord[1][1:-2])
                    school.coordinates = Point(y, x)

                school.save()

                # staff
                if row[12]:
                    staff1, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.TSC_MALE,
                        number=row[12].strip(), is_teacher=True)
                if row[13]:
                    staff2, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.TSC_FEMALE,
                        number=row[13].strip(), is_teacher=True)
                if row[14]:
                    staff3, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.LOCAL_MALE,
                        number=row[14].strip(), is_teacher=True)
                if row[15]:
                    staff4, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.LOCAL_FEMALE,
                        number=row[15].strip(), is_teacher=True)
                if row[16]:
                    staff5, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.PTA_MALE,
                        number=row[16].strip(), is_teacher=True)
                if row[17]:
                    staff6, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.PTA_FEMALE,
                        number=row[17].strip(), is_teacher=True)
                if row[18]:
                    staff7, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.OTHER_MALE,
                        number=row[18].strip(), is_teacher=True)
                if row[19]:
                    staff8, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.OTHER_FEMALE,
                        number=row[19].strip(), is_teacher=True)
                if row[20]:
                    staff9, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.NON_TEACHING_MALE,
                        number=row[20].strip(), is_teacher=False)
                if row[21]:
                    staff10, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.NON_TEACHING_FEMALE,
                        number=row[21].strip(), is_teacher=False)

                # facts
                if row[8]:
                    fact1, created = Fact.objects.get_or_create(name="Total Enrolment", period=period, school=school,
                        value=row[8].strip())
                if row[9]:
                    fact2, created = Fact.objects.get_or_create(name="Pupil Teacher Ratio", period=period, school=school,
                        value=row[9].strip())
                if row[10]:
                    fact3, created = Fact.objects.get_or_create(name="Total Teaching staff", period=period, school=school,
                        value=row[10].strip())
                if row[11]:
                    fact4, created = Fact.objects.get_or_create(name="Acreage per enrolment", period=period, school=school,
                        value=row[11].strip())
                if row[22]:
                    fact5, created = Fact.objects.get_or_create(name="Acreage", period=period, school=school,
                        value=row[22].strip())

            n += 1
コード例 #13
0
def cb(count,ds):
  school = None
  try:
    school = School.objects.get(gsid=ds["universal-id"])
  except:
    school = School()

#  print "called for num:" + str(count) + "val: " + str(ds)

  school.name = ds["name"]
  school.gsid = ds["universal-id"]
  school.city = ds["city"]
  if len(ds["zip"]) > 6:
    ds["zip"] = ds["zip"][:6]
  school.zip = ds["zip"]
  school.state = ds["state"]
  school.lat = ds["lat"]
  school.lon = ds["lon"]
  school.gsurl = ds["url"]

  if len(ds["street"]) > 50:
    ds["street"] = ds["street"][:49]
  
  school.street = ds["street"]

  if len(ds["level"]) > 20:
    ds["level"] = ds["level"][:19]
  
  school.level = ds["level"]


  if len(ds["phone"]) > 20:
    ds["phone"] = ds["phone"][:19]
  
  school.phone = ds["phone"]


  if len(ds["subtype"]) > 50:
    ds["subtype"] = 'special'
  school.type = ds["subtype"]


  if len(ds["district-name"]) > 50:
    ds["district-name"] = ds["district-name"][:49]
  
  school.district_name = ds["district-name"]

#  try:
  print school.gsurl
  school.save()
コード例 #14
0
ファイル: importdata1.py プロジェクト: klpdotorg/dubdubdub
    def handle(self, *args, **options):
        filename, self.image_location = args
        file = open(filename, 'r')
        self.data = csv.DictReader(file)
        dev_user = User.objects.get(email='*****@*****.**')

        for d in self.data:
            # ,Unnamed: 0_x,S No_x,Date,Block,Cluster,School Name_spotways,
            # KLP ID,Address,PIN Code,PlayGround?,Fence?,Landmark #1,
            # Landmark #2,Route to School,Bus Details,
            # LAT_spotways,LONG_spotways,Unnamed: 0_y,S No_y,klp_district,
            # klp_block,klp_cluster,dise_code,School Name_ems,category,
            # management,LAT_ems,LONG_ems,institution_gender,hierarchy,moi
            klpid = d['KLP ID']
            address = d['Address']
            landmark = d['Landmark #1']
            bus = d['Bus Details']
            pincode = d['PIN Code']
            lat = d['LAT_spotways']
            lon = d['LONG_spotways']
            coordinates = 'POINT (' + lon + ' ' + lat + ')'

            connection, cursor = self.connectKlpCoord()

            if klpid.startswith('5'):
                continue

            print '=' * 20

            try:
                school = School.objects.get(id=klpid)
            except School.DoesNotExist:
                # School doesn't exist
                print 'Creating new school with id: %s' % klpid
                print d
                school = School(id=klpid,
                                name=d.get('School Name_ems'),
                                cat=d.get('category'),
                                sex=d.get('institution_gender', 'co-ed'),
                                moi=d.get('moi', 'kannada') or 'kannada',
                                mgmt=d.get('management', 'ed'),
                                status=2)
                school.admin3 = self.get_or_create_admin3(d)

            if address:
                if school.address and (not school.address == address):
                    school_address = school.address
                    school_address.address = address
                else:
                    print 'Creating new address for klpid: %s' % klpid
                    school_address = Address.objects.create(address=address)
                    school.address = school_address

            # Update address details.
            if landmark:
                school_address.landmark = landmark
            if bus:
                school_address.bus = bus
            if pincode:
                school_address.pincode = pincode

            school_address.save()
            school.save()

            # Story
            story = {
                'date': d['Date'],
                'user': dev_user,
                'email': '*****@*****.**',
                'name': 'Team KLP',
                'school': school
            }

            self.createStory(story, klpid, d)

            if lat.strip() and lon.strip():
                self.updateCoord(cursor, klpid, coordinates)

            cursor.close()
            connection.commit()
            connection.close()
コード例 #15
0
def load_schools(filePath):
    file = open(filePath, 'r')
    a = []
    for i in file:
        a.append(i.strip('\n'))
    b = []
    for i in a:
        b.append(i.split(','))
    b.pop(0)
    for i in b:
        # r = School.objects.filter(centre_code=i[0])
        # if not r:
        sch = School()
        sch.centre_code = i[0]
        sch.centre_name = i[1]
        sch.level = i[2]
        sch.program_hours = i[3]
        sch.language = i[4]
        if i[5] == 'na':
            sch.vacancy = False
        else:
            sch.vacancy = True
        try:
            sch.registration_fee = float(i[6])
            sch.fee = float(i[7])
        except Exception as e:
            sch.registration_fee = float(0)
            sch.fee = float(0)
        sch.save()
    else:
        pass
コード例 #16
0
    def process_row(self, row, year):
        try:
            school = School.objects.get(code=int(row[self.INDEXES['School_Code']]))
        except Exception as e:
            school = School(
                code=int(row[self.INDEXES['School_Code']]),
                name="School@%s" % int(row[self.INDEXES['School_Code']])
            )
            school.save()
            print "created", str(school)

        yearly_data, created = YearlyData.objects.get_or_create(
            school=school,
            academic_year=year
        )
        yearly_data.area_type = row[self.INDEXES['Rural_Urban']]

        try:
            medium = InstractionMedium.objects.get(id=int(row[self.INDEXES['Medium_of_Instruction']]))
            yearly_data.mediums.add(medium)
        except:
            pass

        yearly_data.distance_from_brc = row[self.INDEXES['Distance_BRC']]
        yearly_data.distance_from_crc = row[self.INDEXES['Distance_CRC']]

        school.year_established = row[self.INDEXES['Yeur_Estd']]
        school.save()

        yearly_data.pre_primary_available = row[self.INDEXES['Pre_Pry_YN']]
        yearly_data.pre_primary_student_count = row[self.INDEXES['Pre_Pry_Students']]
        yearly_data.pre_primary_teacher_count = row[self.INDEXES['Pre_Pry_Teachers']]

        yearly_data.residential = row[self.INDEXES['Residential_Sch_YN']]
        try:
            res_type = ResidentialType.objects.get(id=int(row[self.INDEXES['Residential_Sch_Type']]))
        except:
            print 'Unknown ResidentialType found', school.id, row[self.INDEXES['Residential_Sch_Type']]
            res_type = ResidentialType(
                id=int(row[self.INDEXES['Residential_Sch_Type']]),
                name="Unknown"
            )
            res_type.save()
        yearly_data.residential_type = res_type

        try:
            mgmt = SchoolManaagement.objects.get(id=int(row[self.INDEXES['Sch_Management']]))
        except:
            print 'Unknown Management found', school.id, row[self.INDEXES['Sch_Management']]
            mgmt = SchoolManaagement(
                id=int(row[self.INDEXES['Sch_Management']]),
                name="Unknown"
            )
            mgmt.save()

        yearly_data.management = mgmt

        yearly_data.lowest_class = int(row[self.INDEXES['Lowest_Class']])
        yearly_data.highest_class = int(row[self.INDEXES['Highest_Class']])

        try:
            category = SchoolCategory.objects.get(id=int(row[self.INDEXES['Sch_Category']]))
        except:
            print 'Unknown Category found', school.id, row[self.INDEXES['Sch_Category']]
            category = SchoolCategory(
                id=int(row[self.INDEXES['Sch_Category']]),
                name="Unknown"
            )
            category.save()
        yearly_data.category = category

        yearly_data.type = row[self.INDEXES['School_Type']]
        yearly_data.part_of_shift = row[self.INDEXES['Shift_School_YN']]
        yearly_data.working_day_count = row[self.INDEXES['No_of_Working_Days']]

        yearly_data.academic_inspection_count = row[self.INDEXES['No_of_Acad_Inspection']]
        yearly_data.brc_visit_count = row[self.INDEXES['Visits_by_BRC']]
        yearly_data.crc_visit_count = row[self.INDEXES['Visits_by_CRC']]

        yearly_data.development_grant_received = float(row[self.INDEXES['School_Dev_Grant_Recd']])
        yearly_data.development_grant_expenditure = float(row[self.INDEXES['School_Dev_Grant_Expnd']])
        yearly_data.tlm_grant_received = float(row[self.INDEXES['TLM_Grant_Recd']])
        yearly_data.tlm_grant_expenditure = float(row[self.INDEXES['TLM_Grant_Expnd']])
        yearly_data.fund_from_student_received = float(row[self.INDEXES['Funds_from_students_Recd']])
        yearly_data.fund_from_student_expenditure = float(row[self.INDEXES['Funds_from_students_Expnd']])

        yearly_data.save()
コード例 #17
0
from .models import Posts


# Create your views here.
def post_list_view(request):
    post_objects = Posts.objects.all()
    context = {
        'post_objects': post_objects
    }
    return render(request, "posts/index.html", context) #posts/index.html should be under appname/templates/appname/index.html

#==================
python3 manage.py shell
from schools.models import School
School.objects.all()
school = School(name='Upperhill',code='2003',address='Nyeri',no_of_students=10)
school.save()
School.objects.all()

#models example under manage.py

#important codes
sudo apt install python3-pip
sudo apt-get install mysql-client
pip install mysqlclient
source env/bin/activate
python3 manage.py runserver
python3 manage.py startapp transactions
python(3) -m venv env
pip install django
#if the database is ot available during migrations,add this in init.py
コード例 #18
0
def import_primary_schools():
    period = datetime.datetime(day=31, month=12, year=2007)
    filename = "%s/documentation/data/2007/primary.csv" % settings.BASE_DIR
    n = 1
    with open(filename, "rb") as ifile:
        reader = csv.reader(ifile)
        for row in reader:
            if n > 1:
                school = School()
                school.name = row[0].strip()
                school.level = School.PRIMARY
                school.ownership = get_ownership(row[2].strip())
                school.sponsor = get_sponsor(row[3].strip())
                school.student_gender = get_student_gender(row[4].strip())
                school.school_type = get_school_type(row[5].strip())
                school.student_needs = get_student_needs(row[6].strip())

                # location
                if row[29]:
                    county, created = County.objects.get_or_create(name=row[29].strip().upper())
                    school.county = county
                    province, created = Province.objects.get_or_create(name=row[28].strip().upper())
                    school.province = province

                    if row[33]:
                        constituency = Constituency.objects.filter(name=row[33].strip().upper()).first()
                        if not constituency:
                            constituency, created = Constituency.objects.get_or_create(
                                name=row[33].strip().upper(), county=county)
                        school.constituency = constituency
                    if row[30]:
                        district = District.objects.filter(name=row[30].strip().upper()).first()
                        if not district:
                            district, created = District.objects.get_or_create(
                                name=row[30].strip().upper(), province=province)
                        school.district = district
                    if row[31]:
                        division, created = Division.objects.get_or_create(
                            name=row[31].strip().upper(), district=district)
                        school.division = division
                    if row[32]:
                        location, created = Location.objects.get_or_create(
                            name=row[32].strip().upper(), division=division)
                        school.location = location

                    if row[34]:
                        coord = row[34].split(",")
                        x = float(coord[0][1:])
                        y = float(coord[1][1:-2])
                        school.coordinates = Point(y, x)

                    school.save()

                    # facilities
                    facility1, created = Facility.objects.get_or_create(name="Toilets")
                    facility2, created = Facility.objects.get_or_create(name="Classrooms")
                    facility3, created = Facility.objects.get_or_create(name="Enrollment")

                    facility_record1, created = FacilityRecord.objects.get_or_create(facility=facility1, school=school, period=period, boys=row[11].strip(),
                                                                                     girls=row[12].strip(), total=row[13].strip())
                    facility_record3, created = FacilityRecord.objects.get_or_create(facility=facility3, school=school, period=period, boys=row[15].strip(),
                                                                                     girls=row[16].strip(), total=row[17].strip())

                    # staff
                    if row[18]:
                        staff1, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.TSC_MALE,
                                                                      number=row[18].strip(), is_teacher=True)
                    if row[19]:
                        staff2, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.TSC_FEMALE,
                                                                      number=row[19].strip(), is_teacher=True)
                    if row[20]:
                        staff3, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.LOCAL_MALE,
                                                                      number=row[20].strip(), is_teacher=True)
                    if row[21]:
                        staff4, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.LOCAL_FEMALE,
                                                                      number=row[21].strip(), is_teacher=True)
                    if row[22]:
                        staff5, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.PTA_MALE,
                                                                      number=row[22].strip(), is_teacher=True)
                    if row[23]:
                        staff6, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.PTA_FEMALE,
                                                                      number=row[23].strip(), is_teacher=True)
                    if row[24]:
                        staff7, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.OTHER_MALE,
                                                                      number=row[24].strip(), is_teacher=True)
                    if row[25]:
                        staff8, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.OTHER_FEMALE,
                                                                      number=row[25].strip(), is_teacher=True)
                    if row[26]:
                        staff9, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.NON_TEACHING_MALE,
                                                                      number=row[26].strip(), is_teacher=False)
                    if row[27]:
                        staff10, created = Staff.objects.get_or_create(period=period, school=school, staff_type=Staff.NON_TEACHING_FEMALE,
                                                                       number=row[27].strip(), is_teacher=False)

                    # facts
                    if row[7]:
                        fact2, created = Fact.objects.get_or_create(name="Pupil Teacher Ratio", period=period, school=school,
                                                                    value=row[7].strip())
                    if row[8]:
                        fact1, created = Fact.objects.get_or_create(name="Pupil Classroom Ratio", period=period, school=school,
                                                                    facility=facility2, value=row[8].strip())
                    if row[9]:
                        fact4, created = Fact.objects.get_or_create(name="Pupil Toilet Ratio", period=period, school=school,
                                                                    facility=facility1, value=row[9].strip())
                    if row[10]:
                        fact5, created = Fact.objects.get_or_create(name="Total Number of Classrooms", period=period, school=school,
                                                                    facility=facility2, value=row[10].strip())
                    if row[14]:
                        fact5, created = Fact.objects.get_or_create(name="Teachers Toilets", period=period, school=school,
                                                                    facility=facility1, value=row[14].strip())

            n += 1