Much data added. RouteDetails has 3 dirty rows, pls see RouteDetailsErrors file

This commit is contained in:
Johnson Chetty 2011-12-14 00:16:42 +05:30
parent 95e8de70eb
commit 1afff0df5d
8 changed files with 20090 additions and 19924 deletions

View 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.

View File

@ -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]))
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()

View File

@ -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|
@ -61,7 +79,52 @@ class RouteTypes(models.Model):
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)

View File

@ -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)),
)

View 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
1 Hard Coded Routes Route Alias Fare Type
2 8011 SPL-1 LTD
3 8021 SPL-2 LTD
4 8031 SPL-3 LTD
5 8041 SPL-4 LTD
6 8051 SPL-5 LTD
7 8061 SPL-6 LTD
8 8081 SPL-8 LTD
9 8091 SPL-9 LTD
10 3027 AS-302 AS
11 5157 AS-515 AS
12 0057 AS-5 AS
13 7007 AS-700 AS
14 0047 AS-4 AS
15 0097 AS-9 AS
16 0138 A-13EXP ACEXP
17 0708 A-70EXP ACEXP
18 0758 A-75EXP ACEXP
19 0748 A-74EXP ACEXP
20 0768 A-76EXP ACEXP
21 0778 A-77EXP ACEXP
22 9699 A-13EXP EXT ACEXP
23 7077 AS-707 AS
24 4587 AS-458 AS
25 5517 AS-551 AS
26 3887 AS-388 AS
27 5257 AS-525 AS
28 5259 AS-525EXT AS
29 4617 AS-461 AS
30 4227 AS-422 AS
31 0017 AS-1 AS
32 0037 AS-3 AS
33 0027 AS-2 AS
34 5037 AS-503 AS
35 5057 AS-505 AS
36 5927 AS-592 AS
37 5127 AS-512 AS
38 5247 AS-524 AS
39 4407 AS-440 AS
40 0016 C-1 EXP
41 0026 C-2 EXP
42 0426 C-42 EXP
43 0716 C-71 EXP
44 0126 C-12 EXP
45 0606 C-60 EXP
46 0726 C-72 EXP
47 0536 C-53 EXP
48 0616 C-61 EXP
49 0626 C-62 EXP
50 0526 C-52 EXP
51 0436 C-43 EXP
52 0556 C-55 EXP
53 0146 C-14 EXP
54 0446 C-44 EXP
55 0456 C-45 EXP
56 0466 C-46 EXP
57 8521 BANDRA FAIR LTD
58 8111 MAHALAXMI FAIR LTD
59 8126 FORT FERRY-1 EXP
60 8136 FORT FERRY-2 EXP

File diff suppressed because it is too large Load Diff

View 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
1 Route Code Route Type Fare Type
2 0 Ordinary ORD
3 1 Limited LTD
4 2 Ordinary Extra ORD
5 3 Limited Extra LTD
6 4 Ring Ordinary ORD
7 5 Ring Limited LTD
8 6 Express EXP
9 9 AC Exp Ext ACEXP
10 7 AS AS
11 8 ACEXP ACEXP