minor edits to data_mapper and postload
This commit is contained in:
parent
a9dda65feb
commit
07e1c7a1dc
|
@ -6,7 +6,7 @@ import json
|
||||||
import datetime
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
from django.contrib.gis.geos import Point
|
from django.contrib.gis.geos import Point
|
||||||
from imports.import_atlas import getFromToStopsForRoute
|
from imports.import_atlas import getFromToStopsForRoute, importUniqueRoutes
|
||||||
globalerr = []
|
globalerr = []
|
||||||
|
|
||||||
def RouteType_save(entry):
|
def RouteType_save(entry):
|
||||||
|
@ -14,27 +14,6 @@ def RouteType_save(entry):
|
||||||
obj.save()
|
obj.save()
|
||||||
#print obj.__dict__
|
#print obj.__dict__
|
||||||
|
|
||||||
def importRouteMaster():
|
|
||||||
CsvFile = csv.reader(open(join(PROJECT_ROOT, "../db_csv_files/RouteMaster.csv"), "r"), delimiter=',')
|
|
||||||
test = CsvFile.next()
|
|
||||||
stop_errors = []
|
|
||||||
print test
|
|
||||||
for row in CsvFile:
|
|
||||||
if len(row) < 1:
|
|
||||||
continue
|
|
||||||
from_to = getFromToStopsForRoute(row[0])
|
|
||||||
if from_to is None:
|
|
||||||
stop_errors.append(row[0])
|
|
||||||
continue
|
|
||||||
print row[0]
|
|
||||||
obj = Route(code=row[0], alias=row[1], from_stop_txt=row[2], to_stop_txt=row[3], from_stop=from_to[0], to_stop=from_to[1], distance=row[4], stages=int(row[5]))
|
|
||||||
obj.save()
|
|
||||||
errors = open(join(PROJECT_ROOT, "../errors/routeStopErrors.json"), "w")
|
|
||||||
errors.write(json.dumps(stop_errors, indent=2))
|
|
||||||
errors.close()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def Route_save(entry):
|
def Route_save(entry):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
@ -227,7 +206,7 @@ def loadFKinRouteDetail():
|
||||||
rd.route=None
|
rd.route=None
|
||||||
err.append({"data":rd.route_code, "error":["Route Not Found in Route"]})
|
err.append({"data":rd.route_code, "error":["Route Not Found in Route"]})
|
||||||
|
|
||||||
errors = open(join(PROJECT_ROOT, "../errors/RouteNotFoundErrors.json"), "w")
|
#errors = open(join(PROJECT_ROOT, "../errors/RouteNotFoundErrors.json"), "w")
|
||||||
size = len(err)
|
size = len(err)
|
||||||
print "No. of Routes in RouteDetail mapped to Route: " , str(good_saves)
|
print "No. of Routes in RouteDetail mapped to Route: " , str(good_saves)
|
||||||
print "No. of Routes in RouteDetail not mapped to Route: " , str(size)
|
print "No. of Routes in RouteDetail not mapped to Route: " , str(size)
|
||||||
|
@ -235,8 +214,9 @@ def loadFKinRouteDetail():
|
||||||
if (size != 0) :
|
if (size != 0) :
|
||||||
print "See /errors/RouteNotFoundErrors.json for details"
|
print "See /errors/RouteNotFoundErrors.json for details"
|
||||||
|
|
||||||
errors.write(json.dumps(err, indent=2))
|
#errors.write(json.dumps(err, indent=2))
|
||||||
errors.close()
|
#errors.close()
|
||||||
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,6 +264,9 @@ def fire_up():
|
||||||
CsvLoader(model)
|
CsvLoader(model)
|
||||||
|
|
||||||
loadFKinRouteDetail()
|
loadFKinRouteDetail()
|
||||||
|
# also
|
||||||
|
#importUniqueRoutes()
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
from mumbai.models import *
|
from mumbai.models import *
|
||||||
|
|
||||||
|
#"Road, Area, Landmark, Stop"
|
||||||
"Road, Area, Landmark, Stop"
|
|
||||||
|
|
||||||
def copynames2display_name():
|
def copynames2display_name():
|
||||||
for obj in Stop.objects.all():
|
for obj in Stop.objects.all():
|
||||||
obj.display_name =obj.name
|
obj.display_name =obj.name
|
||||||
|
@ -18,7 +16,8 @@ def copynames2display_name():
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
||||||
def copydefaultStopLocations():
|
def copydefaultStopLocations():
|
||||||
for stop in Stop.objects.all():
|
for stp in Stop.objects.all():
|
||||||
stop.stop = stop.stoplocation_set.all()[0]
|
if stp.stoplocation_set.count()>0 :
|
||||||
|
stp.point = stp.stoplocation_set.all()[0].point
|
||||||
|
stp.save()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user