old_contents: from pymongo import MongoClient
  from helpers import db_url, parse_csv, to_int, to_float
  
  mongo = MongoClient(db_url)
  db = mongo.ks5
  
  print("Updating school information from 2013 data...")
  for school in parse_csv("../data/2013/ks5_attainment.csv"):
  
      # All schools are RECTYPE=1. Other RECTYPEs are used for local averages.
      # Closed schools are ICLOSE=1. We skip them too.
      if (school["RECTYPE"] != "1") or (school["ICLOSE"] == "1"):
          continue
  
      db.schools.update(
          { "_id": school["URN"] },
          { "$set": {
                  "lea": to_int(school["LEA"]),
                  "name": school["SCHNAME"],
                  "address": [school["ADDRESS1"], school["ADDRESS2"], school["ADDRESS3"]],
                  "town": school["TOWN"],
                  "postcode": school["PCODE"],
                  "phone": school["TELNUM"],
                  "type": school["NFTYPE"],
                  "religious": school["RELDENOM"],
                  "admissions": school["ADMPOL"],
                  "gender": school["GENDER1618"].capitalize(),
                  "ages": school["AGERANGE"],
                  "primary": bool(to_int(school["TABKS2"])),
                  "secondary": bool(to_int(school["TAB15"])),
                  "performance.2013.students": {
                      "16-18": to_int(school["TPUP1618"], True),
                      "ks5": to_int(school["TALLPUPA"]),
                      "academic": to_int(school["TALLPUP_ACADA"]),
                      "vocational": to_int(school["TALLPUP_VQA"]),
                      "a-level": to_int(school["TALLPUP_ALEVA"])
                  },
                  "performance.2013.aps.a-level": {
                      "student": to_float(school["APSFTE_ALEVA"], True),
                      "entry": to_float(school["TALLPPE_ALEVA"], True)
                  }
              }
          },
          upsert=True
      )
  
      if (school["TPUP1618"] == "NEW"):
          db.schools.update({"_id": school["URN"]}, {"$set": {"new": True}})
  
  
  mongo.disconnect()
  
  print("\nDone.")
new_contents: from pymongo import MongoClient
  from helpers import db_url, parse_csv, to_int, to_float
  
  mongo = MongoClient(db_url)
  db = mongo.ks5
  
  print("Updating school information from 2013 data...")
  for school in parse_csv("../data/2013/ks5_attainment.csv"):
  
      # All schools are RECTYPE=1. Other RECTYPEs are used for local averages.
      # Closed schools are ICLOSE=1. We skip them too.
      if (school["RECTYPE"] != "1") or (school["ICLOSE"] == "1"):
          continue
  
      db.schools.update(
          { "_id": school["URN"] },
          { "$set": {
                  "lea": to_int(school["LEA"]),
                  "name": school["SCHNAME"],
                  "address": [school["ADDRESS1"], school["ADDRESS2"], school["ADDRESS3"]],
                  "town": school["TOWN"],
                  "postcode": school["PCODE"],
                  "phone": school["TELNUM"],
                  "type": school["NFTYPE"],
                  "religious": school["RELDENOM"],
                  "admissions": school["ADMPOL"],
                  "gender": school["GENDER1618"].capitalize(),
                  "ages": school["AGERANGE"],
                  "performance.2013.students": {
                      "16-18": to_int(school["TPUP1618"], True),
                      "ks5": to_int(school["TALLPUPA"]),
                      "academic": to_int(school["TALLPUP_ACADA"]),
                      "vocational": to_int(school["TALLPUP_VQA"]),
                      "a-level": to_int(school["TALLPUP_ALEVA"])
                  },
                  "performance.2013.aps.a-level": {
                      "student": to_float(school["APSFTE_ALEVA"], True),
                      "entry": to_float(school["TALLPPE_ALEVA"], True)
                  }
              }
          },
          upsert=True
      )
  
      if (school["TPUP1618"] == "NEW"):
          db.schools.update({"_id": school["URN"]}, {"$set": {"new": True}})
  
  
  mongo.disconnect()
  
  print("\nDone.")
subject: Remove 'primary' and 'secondary' fields