32 lines
860 B
Python
32 lines
860 B
Python
import os, sys
|
|
proj_path = "/home/gregz09/Pulpit/ordynacje/ordynacje"
|
|
# This is so Django knows where to find stuff.
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ordynacje.settings")
|
|
sys.path.append(proj_path)
|
|
|
|
# This is so my local_settings.py gets loaded.
|
|
os.chdir(proj_path)
|
|
|
|
# This is so models get loaded.
|
|
from django.core.wsgi import get_wsgi_application
|
|
application = get_wsgi_application()
|
|
|
|
from ordynacja.models import Komitet,Okreg,Glos
|
|
|
|
f = open("glosy.csv", "r+").readlines()
|
|
|
|
id_counter = 0
|
|
for i in range(1, len(f)):
|
|
k = f[i].split(",")
|
|
o_ixd = k[0]
|
|
for j in range(25,42):
|
|
tmp = k[j].replace("\xc2\xa0","")
|
|
print(tmp)
|
|
if (tmp == "" or tmp == "\n"):
|
|
tmp = 0
|
|
print(tmp)
|
|
g = Glos(g_id=id_counter, liczba=tmp, komitet=Komitet.objects.filter(kw_id=j-24)[0], okreg=Okreg.objects.filter(o_id=o_ixd)[0])
|
|
g.save()
|
|
id_counter += 1
|
|
|