blob: 62c7ce0acd1417c5bc3da5b32e5d5910e9ecd546 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
from django.conf import settings
import troggle.core.models as models
def load():
folkfile = open(settings.EXPOWEB+"noinfo/folk.csv")
personlines = folkfile.read().splitlines()
persontable = [x.split(',') for x in personlines]
years = [persontable[0][i] for i in range(5,len(persontable[0]))]
for year in years:
newexpedition = models.ExpeditionM( date = year )
newexpedition.save()
for row in persontable[1:]: #skip header
attendedid = [i for i, x in enumerate(row) if '1' in x]
attendedyears = [persontable[0][i] for i in attendedid if i >= 5]
name = row[0]
print(name+' has attended: '+', '.join(attendedyears))
newperson = models.PersonM(
name = name)
newperson.save()
for year in attendedyears:
target = models.ExpeditionM.objects.get(date=year)
newperson.expos_attended.add( target )
print('Person -> Expo table created!')
|