Much data added. RouteDetails has 3 dirty rows, pls see RouteDetailsErrors file
This commit is contained in:
parent
95e8de70eb
commit
1afff0df5d
3
chaloBEST/RouteDetailsErrors
Normal file
3
chaloBEST/RouteDetailsErrors
Normal file
|
@ -0,0 +1,3 @@
|
|||
<class 'mumbai.models.DoesNotExist'>['2884', '11', '3900', '0', '0.0']
|
||||
<class 'mumbai.models.DoesNotExist'>['4354', '11', '2313', '0', '0.0']
|
||||
<class 'mumbai.models.DoesNotExist'>['6250', '15', '3900', '0', '0.0']
|
Binary file not shown.
|
@ -10,7 +10,7 @@ for entry in CsvFile:
|
|||
|
||||
print "----- "
|
||||
|
||||
CsvFile = csv.reader(open("/home/johnson/Desktop/chaloBEST/db_csv_files/FareMaster.csv", "r"))
|
||||
CsvFile = csv.reader(open("/home/johnson/Desktop/chaloBEST/chaloBEST/db_csv_files/FareMaster.csv", "r"))
|
||||
test = CsvFile.next()
|
||||
print test
|
||||
for entry in CsvFile:
|
||||
|
@ -36,13 +36,43 @@ for entry in CsvFile:
|
|||
print obj.__dict__
|
||||
|
||||
|
||||
CsvFile = csv.reader(open("/home/johnson/Desktop/chaloBEST/db_csv_files/RouteDetails.csv", "r"))
|
||||
CsvFile = csv.reader(open("/home/johnson/Desktop/chaloBEST/db_csv_files/RouteDetails.csv", "r"), delimiter='\t')
|
||||
test = CsvFile.next()
|
||||
print test
|
||||
for entry in CsvFile:
|
||||
obj = RouteDetails(rno=entry[0], stopsr=int(entry[1]), stopcd=int(entry[2]), stage=entry[3].startswith('TRUE'), km=float(entry[4]))
|
||||
print obj.__dict__
|
||||
try:
|
||||
print obj.__dict__
|
||||
obj = RouteDetails(rno=entry[0], stopsr=int(entry[1]), stopdcd=Stop.objects.get(stopcd=int(entry[2])), stage=entry[3].startswith('1'), km=float(entry[4]))
|
||||
|
||||
except:
|
||||
f.write(obj.__dict__)
|
||||
|
||||
RNO,STOPSR,STOPCD,STAGE,KM
|
||||
|
||||
CsvFile = csv.reader(open("/home/johnson/Desktop/chaloBEST/chaloBEST/db_csv_files/RouteDetails.csv", "r"), delimiter='\t')
|
||||
f= open('RouteDetailsErrors', 'w')
|
||||
test = CsvFile.next()
|
||||
print test
|
||||
for entry in CsvFile:
|
||||
try:
|
||||
obj = RouteDetails(rno=entry[0], stopsr=int(entry[1]), stopcd=Stop.objects.get(stopcd=int(entry[2])), stage=(lambda:entry[3].startswith('1'), lambda:None)[ entry[3] == '' ](), km=(lambda:None,lambda:float(entry[4]))[ entry[4] != '' ]() )
|
||||
obj.save()
|
||||
obj.__dict__
|
||||
except :
|
||||
f.write(str(sys.exc_info()[0]) + str(entry))
|
||||
print "Unexpected error:", sys.exc_info()[0]
|
||||
|
||||
f.close()
|
||||
|
||||
|
||||
RouteTypes
|
||||
data changed
|
||||
5 Rind Limited LTD
|
||||
to
|
||||
5 Ring Limited LTD
|
||||
9 A/C Exp Ext ACEXP
|
||||
to
|
||||
9 AC Exp Ext ACEXP
|
||||
|
||||
|
||||
test = CsvFile.next()
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
from django.contrib.gis.db import models
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
class Area(models.Model):
|
||||
a_code = models.IntegerField(primary_key=True)
|
||||
areanm = models.TextField(blank=True, max_length=255)
|
||||
def __unicode__(self):
|
||||
return self.areanm
|
||||
|
||||
class Road(models.Model):
|
||||
roadcd = models.IntegerField(primary_key=True)
|
||||
roadnm = models.TextField(blank=True, max_length=255)
|
||||
def __unicode__(self):
|
||||
return self.roadnm
|
||||
|
||||
|
||||
class Fare(models.Model):
|
||||
slab = models.DecimalField(max_digits=5, decimal_places=2)
|
||||
|
@ -15,6 +22,9 @@ class Fare(models.Model):
|
|||
express = models.PositiveIntegerField(db_column='exp')
|
||||
ac = models.PositiveIntegerField(db_column='as')
|
||||
ac_express = models.PositiveIntegerField(db_column='acexp')
|
||||
def __unicode__(self):
|
||||
return self.slab
|
||||
|
||||
|
||||
STOP_CHOICES = ( ('U','Up'),
|
||||
('D', 'Down'),
|
||||
|
@ -29,12 +39,17 @@ class Stop(models.Model):
|
|||
a_code = models.ForeignKey(Area)
|
||||
depot = models.TextField(max_length=255) # should actually be a foreign key to a depotMaster,
|
||||
|
||||
def __unicode__(self):
|
||||
return self.stopnm
|
||||
|
||||
class RouteDetails(models.Model):
|
||||
rno = models.TextField()
|
||||
stopsr = models.PositiveIntegerField()
|
||||
stopcd = models.ForeignKey(Stop)
|
||||
stage = models.BooleanField()
|
||||
km = models.DecimalField(max_digits=3, decimal_places=1)
|
||||
stage = models.NullBooleanField()
|
||||
km = models.DecimalField(null=True, blank=True, max_digits=3, decimal_places=1)
|
||||
def __unicode__(self):
|
||||
return self.rno
|
||||
|
||||
|
||||
|
||||
|
@ -49,6 +64,9 @@ class Route(models.Model):
|
|||
distance = models.DecimalField(max_digits=3, decimal_places=1)
|
||||
stages = models.IntegerField()
|
||||
|
||||
def __unicode__(self):
|
||||
return self.route
|
||||
|
||||
######j: A logic to find out the routetype/ route code in every bus.
|
||||
# 1. Separate the route code into the first 3 digits, and the ending
|
||||
# 2. i.e. |routecode| becomes | routenum | routetypecode|
|
||||
|
@ -60,8 +78,53 @@ class RouteTypes(models.Model):
|
|||
routecode = models.TextField(max_length=50)
|
||||
routetype = models.TextField(max_length=50)
|
||||
faretype = models.TextField(max_length=10)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.routetype
|
||||
|
||||
|
||||
class HardCodedRoutes(models.Model):
|
||||
routecode = models.TextField(max_length=50)
|
||||
routealias = models.TextField(max_length=50)
|
||||
faretype = models.TextField(max_length=10)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.routecode + " " +self.routealias
|
||||
|
||||
|
||||
class AreaAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
class RoadAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
class FareAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
class StopAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
class RouteDetailsAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
class RouteAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
class RouteTypesAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
class HardCodedRoutesAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
|
||||
admin.site.register(Area, AreaAdmin)
|
||||
admin.site.register(Road, RoadAdmin)
|
||||
admin.site.register(Fare,FareAdmin)
|
||||
|
||||
admin.site.register(Stop, StopAdmin)
|
||||
admin.site.register(RouteDetails, RouteDetailsAdmin)
|
||||
admin.site.register(Route, RouteAdmin)
|
||||
|
||||
admin.site.register(RouteTypes, RouteTypesAdmin)
|
||||
admin.site.register(HardCodedRoutes, HardCodedRoutesAdmin)
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
from django.conf.urls.defaults import *
|
||||
|
||||
# Uncomment the next two lines to enable the admin:
|
||||
# from django.contrib import admin
|
||||
# admin.autodiscover()
|
||||
from django.contrib import admin
|
||||
admin.autodiscover()
|
||||
|
||||
urlpatterns = patterns('',
|
||||
# Example:
|
||||
# (r'^chaloBEST/', include('chaloBEST.foo.urls')),
|
||||
|
||||
# Uncomment the admin/doc line below to enable admin documentation:
|
||||
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
||||
# Uncomment the next line to enable the admin:
|
||||
# (r'^admin/', include(admin.site.urls)),
|
||||
(r'^admin/', include(admin.site.urls)),
|
||||
)
|
||||
|
|
60
db_csv_files/HardCodedRoutes.csv
Normal file
60
db_csv_files/HardCodedRoutes.csv
Normal file
|
@ -0,0 +1,60 @@
|
|||
Hard Coded Routes Route Alias Fare Type
|
||||
8011 SPL-1 LTD
|
||||
8021 SPL-2 LTD
|
||||
8031 SPL-3 LTD
|
||||
8041 SPL-4 LTD
|
||||
8051 SPL-5 LTD
|
||||
8061 SPL-6 LTD
|
||||
8081 SPL-8 LTD
|
||||
8091 SPL-9 LTD
|
||||
3027 AS-302 AS
|
||||
5157 AS-515 AS
|
||||
0057 AS-5 AS
|
||||
7007 AS-700 AS
|
||||
0047 AS-4 AS
|
||||
0097 AS-9 AS
|
||||
0138 A-13EXP ACEXP
|
||||
0708 A-70EXP ACEXP
|
||||
0758 A-75EXP ACEXP
|
||||
0748 A-74EXP ACEXP
|
||||
0768 A-76EXP ACEXP
|
||||
0778 A-77EXP ACEXP
|
||||
9699 A-13EXP EXT ACEXP
|
||||
7077 AS-707 AS
|
||||
4587 AS-458 AS
|
||||
5517 AS-551 AS
|
||||
3887 AS-388 AS
|
||||
5257 AS-525 AS
|
||||
5259 AS-525EXT AS
|
||||
4617 AS-461 AS
|
||||
4227 AS-422 AS
|
||||
0017 AS-1 AS
|
||||
0037 AS-3 AS
|
||||
0027 AS-2 AS
|
||||
5037 AS-503 AS
|
||||
5057 AS-505 AS
|
||||
5927 AS-592 AS
|
||||
5127 AS-512 AS
|
||||
5247 AS-524 AS
|
||||
4407 AS-440 AS
|
||||
0016 C-1 EXP
|
||||
0026 C-2 EXP
|
||||
0426 C-42 EXP
|
||||
0716 C-71 EXP
|
||||
0126 C-12 EXP
|
||||
0606 C-60 EXP
|
||||
0726 C-72 EXP
|
||||
0536 C-53 EXP
|
||||
0616 C-61 EXP
|
||||
0626 C-62 EXP
|
||||
0526 C-52 EXP
|
||||
0436 C-43 EXP
|
||||
0556 C-55 EXP
|
||||
0146 C-14 EXP
|
||||
0446 C-44 EXP
|
||||
0456 C-45 EXP
|
||||
0466 C-46 EXP
|
||||
8521 BANDRA FAIR LTD
|
||||
8111 MAHALAXMI FAIR LTD
|
||||
8126 FORT FERRY-1 EXP
|
||||
8136 FORT FERRY-2 EXP
|
|
File diff suppressed because it is too large
Load Diff
11
db_csv_files/RouteTypes.csv
Normal file
11
db_csv_files/RouteTypes.csv
Normal file
|
@ -0,0 +1,11 @@
|
|||
Route Code Route Type Fare Type
|
||||
0 Ordinary ORD
|
||||
1 Limited LTD
|
||||
2 Ordinary Extra ORD
|
||||
3 Limited Extra LTD
|
||||
4 Ring Ordinary ORD
|
||||
5 Ring Limited LTD
|
||||
6 Express EXP
|
||||
9 AC Exp Ext ACEXP
|
||||
7 AS AS
|
||||
8 ACEXP ACEXP
|
|
Loading…
Reference in New Issue
Block a user