def load_data_private_lo_youth(apps, schema): with open("csvs/niepubliczne_lo_mlodziez.csv", newline="") as csv_file: csv_reader = csv.reader(csv_file, delimiter=",") row_number = 0 for row in csv_reader: if row_number == 0: row_number += 1 else: row_number += 1 print(f"row {row_number} inserted") school = School() address = Address() address.district = row[0] # some schools have different locations written in brackets with their name school.school_name = row[1].split("(")[0] address.street = row[2] address.building_nr = row[3] address.postcode = row[4].strip() address.city = row[5] data = PrivateInstitutionData() data.registration_nr = row[6] school.school_type = "liceum ogólnokształcące" school.school_type_generalised = "szkoła ponadpodstawowa" school.student_type = "dzieci lub młodzież" school.address = address school.private_institution_data = data school.is_public = False data.save() address.save() school.save()
def load_data_private_lo_adult(apps, schema): with open('csvs/niepubliczne_lo_dorosli.csv', newline='') as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') row_number = 0 for row in csv_reader: if row_number == 0: row_number += 1 else: row_number += 1 print(f'row {row_number} inserted') school = School() address = Address() address.district = row[0] # some schools have different locations written in brackets with their name school.school_name = row[1].split('(')[0] address.street = row[2] address.building_nr = row[3] address.postcode = row[4].strip() address.city = row[5] data = PrivateInstitutionData() data.registration_nr = row[6] school.school_type = 'liceum ogólnokształcące' school.school_type_generalised = 'szkoła ponadpodstawowa' school.student_type = 'dorosli' school.address = address school.private_institution_data = data school.is_public = False data.save() address.save() school.save()
def load_data_private_technikum(apps, schema): with open("csvs/niepubliczne_technika_mlodziez.csv", newline="") as csv_file: csv_reader = csv.reader(csv_file, delimiter=",") row_number = 0 for row in csv_reader: if row_number == 0: row_number += 1 else: row_number += 1 print(f"row {row_number} inserted") school = School() address = Address() address.district = row[0] school.school_name = row[1].split("(")[0] if school.school_name is None: continue address.street = row[2] address.building_nr = row[3] address.postcode = row[4].strip() address.city = row[5] # clean profession column data = re.sub(r" +", "\n", row[6]) data = re.sub(r", ", "\n", data) data = data.strip().strip("- ").strip("-").strip(",") profs = data.lower().splitlines() profs = list(filter(None, profs)) school.data = {"zawód": profs} data = PrivateInstitutionData() data.registration_nr = row[7] school.private_institution_data = data school.is_public = False school.registration_nr = row[7] school.school_type = "technikum" school.school_type_generalised = "szkoła ponadpodstawowa" school.student_type = "dzieci lub młodzież" school.address = address data.save() address.save() school.save()
def load_data_private_policealne(apps, schema): with open('csvs/niepubliczne_policealne.csv', newline='') as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') row_number = 0 for row in csv_reader: if row_number == 0: row_number += 1 else: row_number += 1 print(f'row {row_number} inserted') school = School() address = Address() address.district = row[0] school.school_name = row[1].split('(')[0] if school.school_name is None: continue address.street = row[2] address.building_nr = row[3] address.postcode = row[4].strip() address.city = row[5] # clean profession column data = re.sub(r" +", "\n", row[6]) data = re.sub(r", ", "\n", data) data = data.strip().strip('- ').strip('-').strip(',') profs = data.lower().splitlines() profs = list(filter(None, profs)) school.data = {'zawód': profs} data = PrivateInstitutionData() data.registration_nr = row[7] school.private_institution_data = data school.is_public = False school.school_type = 'szkoła policealna' school.school_type_generalised = 'szkoła policealna' school.student_type = 'bez kategorii' school.address = address data.save() address.save() school.save()
def load_data_private_lo_adult(apps, schema): with open("csvs/niepubliczne_lo_mlodziez.csv", newline="") as csv_file: csv_reader = csv.reader(csv_file, delimiter=",") row_number = 0 for row in csv_reader: if row_number == 0: row_number += 1 else: school = PrivateSchool() address = Address() address.district = row[0] school.school_name = row[1] address.street = row[2] address.building_nr = row[3] address.postcode = row[4].strip() address.city = row[5] school.registration_nr = row[6] school.school_type = "liceum ogólnokształcące" school.school_type_generalised = "szkoła ponadpodstawowa" school.student_type = "dorosli" school.address = address address.save() school.save()
def load_data(apps, schema_editor): with open("publiczne.csv", newline="") as csv_file: csv_reader = csv.reader(csv_file, delimiter=",") row_number = 0 for row in csv_reader: if row_number == 0: row_number += 1 elif row[46] != "jednostka inna niż przedszkole lub szkoła": for col in row: if len(col) > 100: print(col) school = PublicSchool() public_data = PublicInstitutionData() public_data.institution_short_name = row[0] public_data.short_name = row[1] public_data.institution_regon = row[2] public_data.regon = row[3] public_data.institution_RSPO = row[4] public_data.RSPO = row[5] public_data.institution_name = row[6] school.school_name = row[7] public_data.institution_type = row[8] school.school_type = row[9] school.student_type = row[10] school.is_special_needs_school = True if row[11] == "tak" else False public_data.data = {"supervisor": row[12]} address = Address() address.city = row[13] address.district = row[14] public_data.data["information_system"] = row[15] address.street = row[16] address.building_nr = row[17] address.postcode = row[18] contact = ContactData() contact.phone = row[21] contact.website = row[23] public_data.data["BIP"] = row[24] contact.email = row[25] public_data.data["has_dormitory"] = True if row[27] == "tak" else False divisions = [] if row[35] == "tak": divisions.append("dwujęzyczne") if row[36] == "tak": divisions.append("integracyjne") if row[37] == "tak": divisions.append("sportowe") if row[38] == "tak": divisions.append("mistrzostwa sportowego") if row[39] == "tak": divisions.append("międzynarodowe") if row[40] == "tak": divisions.append("specjalne") if row[41] == "tak": divisions.append("specjalne przysposabiające do pracy") if row[42] == "tak": divisions.append("terapeutyczne") if row[43] == "tak": divisions.append("eksperymentalne") school.specialised_divisions = divisions school.data = { "is_in_school_complex": True if row[45] == "tak" else False } if row[46] == "szkoła podstawowa (w tym muzyczna)": school.school_type_generalised = "szkoła podstawowa" else: school.school_type_generalised = row[46] public_data.data["RSPO_url"] = row[60] public_data.data["psychological_clinic"] = row[62] public_data.data["main_disability"] = row[63] public_data.data["is_by_hospital"] = True if row[64] == "tak" else False address.longitude = row[66].replace(",", ".") address.latitude = row[65].replace(",", ".") public_data.data["ankietyBE_id"] = row[69] school.address = address school.contact = contact school.public_institution_data = public_data public_data.save() address.save() contact.save() school.save()
def load_data(apps, schema_editor): with open('csvs/publiczne.csv', newline='') as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') row_number = 0 for row in csv_reader: if row_number == 0: row_number += 1 elif row[46] != 'jednostka inna niż przedszkole lub szkoła': school = School() public_data = PublicInstitutionData() public_data.institution_short_name = row[0] public_data.short_name = row[1] public_data.institution_regon = row[2] public_data.regon = row[3] public_data.institution_RSPO = row[4] public_data.RSPO = row[5] public_data.institution_name = row[6] school.school_name = row[7] public_data.institution_type = row[8] school.school_type = row[9] school.student_type = row[10] school.is_public = True school.is_special_needs_school = True if row[ 11] == "tak" else False public_data.data = {'supervisor': row[12]} address = Address() address.city = row[13] address.district = row[14] public_data.data['information_system'] = row[15] address.street = row[16] address.building_nr = row[17] address.postcode = row[18] contact = ContactData() contact.phone = row[21] contact.website = row[23] public_data.data['BIP'] = row[24] contact.email = row[25] public_data.data[ 'has_dormitory'] = True if row[27] == 'tak' else False divisions = [] if row[35] == 'tak': divisions.append('dwujęzyczne') if row[36] == 'tak': divisions.append('integracyjne') if row[37] == 'tak': divisions.append('sportowe') if row[38] == 'tak': divisions.append('mistrzostwa sportowego') if row[39] == 'tak': divisions.append('międzynarodowe') if row[40] == 'tak': divisions.append('specjalne') if row[41] == 'tak': divisions.append('specjalne przysposabiające do pracy') if row[42] == 'tak': divisions.append('terapeutyczne') if row[43] == 'tak': divisions.append('eksperymentalne') school.specialised_divisions = divisions school.data = { 'is_in_school_complex': True if row[45] == 'tak' else False } if row[46] == 'szkoła podstawowa (w tym muzyczna)': school.school_type_generalised = 'szkoła podstawowa' else: school.school_type_generalised = row[46] public_data.data['RSPO_url'] = row[60] public_data.data['psychological_clinic'] = row[62] public_data.data['main_disability'] = row[63] public_data.data[ 'is_by_hospital'] = True if row[64] == 'tak' else False address.longitude = row[66].replace(',', '.') address.latitude = row[65].replace(',', '.') public_data.data['ankietyBE_id'] = row[69] school.address = address school.contact = contact school.public_institution_data = public_data public_data.save() address.save() contact.save() school.save()