added json files needed for atlas import + edited atlas import for new field names

This commit is contained in:
Sanj 2012-02-02 01:12:32 +05:30
parent fd93e3c708
commit c8369d1b34
2 changed files with 475 additions and 11 deletions

View File

@ -140,22 +140,22 @@ def importUniqueRoutes():
from_to = getFromToStopsForRoute(routeObj.code) from_to = getFromToStopsForRoute(routeObj.code)
obj.from_stop = from_to[0] obj.from_stop = from_to[0]
if not stopMapping.has_key(obj.from_stop_txt): if not stopMapping.has_key(obj.from_stop_txt):
stopMapping[obj.from_stop_txt] = from_to[0].stopcd stopMapping[obj.from_stop_txt] = from_to[0].stop
obj.to_stop = from_to[1] obj.to_stop = from_to[1]
if not stopMapping.has_key(obj.to_stop_txt): if not stopMapping.has_key(obj.to_stop_txt):
stopMapping[obj.to_stop_txt] = from_to[1].stopcd stopMapping[obj.to_stop_txt] = from_to[1].stop
else: #Else we do fuzzy string matching against all possible values for stopname got from RouteDetails else: #Else we do fuzzy string matching against all possible values for stopname got from RouteDetails
stopnames = [] stopnames = []
stopcodes = [] stopcodes = []
for r in RouteDetails.objects.filter(rno=routeObj.code): for r in RouteDetails.objects.filter(route=routeObj):
stopnames.append(r.stopcd.stopnm) stopnames.append(r.stop.name)
stopcodes.append(r.stopcd.stopcd) stopcodes.append(r.stop.code)
from_fuzz = fuzzprocess.extractOne(thisRoute['from'], stopnames) from_fuzz = fuzzprocess.extractOne(thisRoute['from'], stopnames)
to_fuzz = fuzzprocess.extractOne(thisRoute['to'], stopnames) to_fuzz = fuzzprocess.extractOne(thisRoute['to'], stopnames)
#pdb.set_trace() #pdb.set_trace()
try: try:
obj.from_stop = Stop.objects.filter(stopnm=from_fuzz[0]).filter(stopcd__in=stopcodes)[0] obj.from_stop = Stop.objects.filter(name=from_fuzz[0]).filter(code__in=stopcodes)[0]
obj.to_stop = Stop.objects.filter(stopnm=to_fuzz[0]).filter(stopcd__in=stopcodes)[0] obj.to_stop = Stop.objects.filter(name=to_fuzz[0]).filter(code__in=stopcodes)[0]
except: except:
stopErrors.append([thisRoute['from'], thisRoute['to']]) stopErrors.append([thisRoute['from'], thisRoute['to']])
continue continue
@ -166,9 +166,9 @@ def importUniqueRoutes():
for schedule in thisRoute['rows'].keys(): #loop through each schedule per UniqueRoute and save it for schedule in thisRoute['rows'].keys(): #loop through each schedule per UniqueRoute and save it
row = thisRoute['rows'][schedule] row = thisRoute['rows'][schedule]
try: try:
depot = Depot.objects.get(depot_code=row[6]) depot = Depot.objects.get(code=row[6])
except: except:
depot = None depot = None #FIXME!! Catch depot errors based on findings
#pdb.set_trace() #pdb.set_trace()
routeScheduleObj = RouteSchedule(unique_route=obj, schedule_type=schedule, busesAM=noneInt(row[2]), busesN=noneInt(row[3]), busesPM=noneInt(row[4]), bus_type=row[5], depot_txt=row[6], depot=depot, first_from=formatTime(row[8]), last_from=formatTime(row[9]), first_to=formatTime(row[11]), last_to=formatTime(row[12]), runtime1=noneInt(row[14]), runtime2=noneInt(row[15]), runtime3=noneInt(row[16]), runtime4=noneInt(row[17]), headway1=noneInt(row[18]), headway2=noneInt(row[19]), headway3=noneInt(row[20]), headway4=noneInt(row[21]), headway5=noneInt(row[22])) routeScheduleObj = RouteSchedule(unique_route=obj, schedule_type=schedule, busesAM=noneInt(row[2]), busesN=noneInt(row[3]), busesPM=noneInt(row[4]), bus_type=row[5], depot_txt=row[6], depot=depot, first_from=formatTime(row[8]), last_from=formatTime(row[9]), first_to=formatTime(row[11]), last_to=formatTime(row[12]), runtime1=noneInt(row[14]), runtime2=noneInt(row[15]), runtime3=noneInt(row[16]), runtime4=noneInt(row[17]), headway1=noneInt(row[18]), headway2=noneInt(row[19]), headway3=noneInt(row[20]), headway4=noneInt(row[21]), headway5=noneInt(row[22]))
routeScheduleObj.save() routeScheduleObj.save()
@ -225,8 +225,8 @@ def getFromToStopsForRoute(routeCode):
routeDetails = RouteDetails.objects.filter(rno=routeCode).order_by('stopsr') routeDetails = RouteDetails.objects.filter(rno=routeCode).order_by('stopsr')
if routeDetails.count() == 0: if routeDetails.count() == 0:
return None return None
fromStop = routeDetails[0].stopcd fromStop = routeDetails[0].stop
toStop = routeDetails[routeDetails.count() -1].stopcd toStop = routeDetails[routeDetails.count() -1].stop
return (fromStop, toStop,) return (fromStop, toStop,)

View File

@ -0,0 +1,464 @@
{
"4921Ltd": "4921",
"2Ltd": "0021",
"521Ltd": "5211",
"291R": "2914",
"285R": "2854",
"330Ltd": "3301",
"345": "3450",
"346": "3460",
"340": "3400",
"341": "3410",
"342": "3420",
"343": "3430",
"349": "3490",
"11Ltd": "0111",
"321Ltd": "3211",
"494Ltd": "4941",
"355Ltd": "3551",
"489Ltd": "4891",
"517Ltd": "5171",
"298": "2980",
"299": "2990",
"297": "2970",
"707Ltd": "7071",
"295": "2950",
"292": "2920",
"293": "2930",
"204R": "2044",
"606R": "6064",
"271": "2710",
"202Ltd": "2021",
"273": "2730",
"607R": "6074",
"276": "2760",
"277": "2770",
"279": "2790",
"244R": "2444",
"133R": "1334",
"435R": "4354",
"710Ltd": "7101",
"442": "4420",
"441": "4410",
"446": "4460",
"SPL-12": "8041",
"108": "1080",
"238R": "2384",
"502Ltd": "5021",
"103": "1030",
"101": "1010",
"106": "1060",
"39": "0390",
"38": "0380",
"33": "0330",
"511Ltd": "5111",
"37": "0370",
"35": "0350",
"438": "4380",
"434": "4340",
"433": "4330",
"430": "4300",
"431": "4310",
"339": "3390",
"338": "3380",
"335": "3350",
"334": "3340",
"336": "3360",
"333": "3330",
"332": "3320",
"449Ltd": "4491",
"223Ltd": "2231",
"21Ltd": "0211",
"519Ltd": "5191",
"504Ltd": "5041",
"510Ltd": "5101",
"703LtdR": "7035",
"268R": "2684",
"SPL-8": "8081",
"359Ltd": "3591",
"368Ltd": "3681",
"239": "2390",
"515Ltd": "5151",
"157R": "1574",
"236": "2360",
"237": "2370",
"230": "2300",
"231": "2310",
"233": "2330",
"1": "0010",
"450R": "4504",
"105R": "1054",
"414Ltd": "4141",
"234R": "2344",
"610": "6100",
"611": "6110",
"520Ltd": "5201",
"348Ltd": "3481",
"54Ltd": "0541",
"175R": "1754",
"55R": "0554",
"294R": "2944",
"125": "1250",
"130": "1300",
"210Ltd": "2101",
"135": "1350",
"134": "1340",
"495": "4950",
"138": "1380",
"27": "0270",
"28": "0280",
"407": "4070",
"406": "4060",
"405": "4050",
"404": "4040",
"402": "4020",
"401": "4010",
"400": "4000",
"340Ext": "3400",
"408": "4080",
"720Ltd": "7201",
"403Ltd": "4031",
"137R": "1374",
"240R": "2404",
"215R": "2154",
"4Ltd": "0041",
"379": "3790",
"378": "3780",
"371": "3710",
"370": "3700",
"377": "3770",
"376": "3760",
"393": "3930",
"392": "3920",
"391": "3910",
"89": "0890",
"397": "3970",
"395": "3950",
"394": "3940",
"82": "0820",
"83": "0830",
"86": "0860",
"100R": "1004",
"85": "0850",
"479Ltd": "4781",
"413": "4130",
"241": "2410",
"243": "2430",
"6Ltd": "0061",
"615": "6150",
"249": "2490",
"248": "2480",
"461Ltd": "4611",
"419": "4190",
"91Ltd": "0911",
"382Ltd": "3821",
"627": "6270",
"625": "6250",
"624": "6240",
"451": "4510",
"452": "4520",
"454": "4540",
"319": "3190",
"456": "4560",
"344R": "3444",
"174": "1740",
"172": "1720",
"171": "1710",
"170": "1700",
"262R": "2624",
"709Ltd": "7091",
"180": "1800",
"181": "1810",
"186": "1860",
"184": "1840",
"185": "1850",
"702Ltd": "7021",
"205R": "2054",
"525Ltd": "5251",
"211R": "2114",
"15": "0150",
"14": "0140",
"272": "2720",
"245R": "2454",
"706Ltd": "7061",
"443R": "4434",
"104R": "1044",
"80Ltd": "0801",
"62": "0620",
"20Ltd": "0201",
"507Ltd": "5071",
"17Ltd": "0171",
"478Ltd": "4781",
"512Ltd": "5121",
"322": "3220",
"323": "3230",
"320": "3200",
"326": "3260",
"327": "3270",
"324": "3240",
"325": "3250",
"328": "3280",
"329": "3290",
"718Ltd": "7181",
"201": "2010",
"200": "2000",
"203": "2030",
"207": "2070",
"206": "2060",
"208": "2080",
"518Ltd": "5181",
"488Ltd": "4881",
"32R": "0324",
"76": "0760",
"75": "0750",
"74": "0740",
"70": "0700",
"79": "0790",
"8Ltd": "0081",
"701LtdR": "7015",
"664": "6640",
"663": "6630",
"524Ltd": "5241",
"375Ltd": "3751",
"503Ltd": "5031",
"246R": "2464",
"421Ext": "4210",
"16Ltd": "0161",
"491Ltd": "4911",
"252R": "2524",
"120": "1200",
"121": "1210",
"122": "1220",
"123": "1230",
"124": "1240",
"84Ltd": "0841",
"126": "1260",
"22Ltd": "0221",
"545Ltd": "5451",
"498Ltd": "4981",
"415": "4150",
"416": "4160",
"417": "4170",
"410": "4100",
"411": "4110",
"412": "4120",
"209R": "2094",
"396Ltd": "3961",
"306Ltd": "3061",
"399Ltd": "3991",
"81Ltd": "0811",
"318": "3180",
"313": "3130",
"312": "3120",
"311": "3110",
"310": "3100",
"317": "3170",
"316": "3160",
"315": "3150",
"314": "3140",
"30Ltd": "0301",
"469Ltd": "4691",
"513Ltd": "5131",
"308Ext": "3082",
"10Ltd": "0101",
"3": "0030",
"369": "3690",
"366": "3660",
"367": "3670",
"364": "3640",
"365": "3650",
"362": "3620",
"363": "3630",
"360": "3600",
"361": "3610",
"347R": "3474",
"484Ltd": "4841",
"356Ltd": "3561",
"380": "3800",
"381": "3810",
"383": "3830",
"384": "3840",
"385": "3850",
"386": "3860",
"387": "3870",
"514Ltd": "5141",
"290Ltd": "2901",
"226Ltd": "2261",
"711Ltd": "7111",
"605": "6050",
"629R": "6294",
"289R": "2894",
"60": "0600",
"61": "0610",
"258": "2580",
"259": "2590",
"64": "0640",
"65": "0650",
"66": "0660",
"67": "0670",
"68": "0680",
"253": "2530",
"250": "2500",
"251": "2510",
"256": "2560",
"257": "2570",
"254": "2540",
"700Ltd": "7001",
"242R": "2424",
"602": "6020",
"632": "6320",
"398Ltd": "3981",
"630": "6300",
"631": "6310",
"92Ltd": "0921",
"465": "4650",
"464": "4640",
"463": "4630",
"462": "4620",
"168": "1680",
"169": "1690",
"164": "1640",
"165": "1650",
"166": "1660",
"160": "1600",
"161": "1610",
"162": "1620",
"163": "1630",
"40Ltd": "0401",
"460Ltd": "4601",
"300R": "3004",
"522Ltd": "5221",
"19Ltd": "0191",
"409Ltd": "4091",
"26Ltd": "0261",
"9": "0090",
"440Ltd": "4401",
"603R": "6034",
"622R": "6224",
"705Ltd": "7051",
"523Ltd": "5231",
"357": "3570",
"354": "3540",
"353": "3530",
"352": "3520",
"351": "3510",
"350": "3500",
"453Ltd": "4531",
"214": "2140",
"155R": "1554",
"212": "2120",
"213": "2130",
"497Ltd": "4971",
"219": "2190",
"288": "2880",
"281": "2810",
"280": "2800",
"283": "2830",
"282": "2820",
"287": "2870",
"286": "2860",
"444Ltd": "4441",
"263": "2630",
"261": "2610",
"266": "2660",
"265": "2650",
"264": "2640",
"470Ltd": "4701",
"269": "2690",
"167R": "1674",
"59": "0590",
"296R": "2964",
"57": "0570",
"56": "0560",
"51": "0510",
"50": "0500",
"53": "0530",
"52": "0520",
"25Ltd": "0251",
"63": "0630",
"279Ext": "2790",
"619R": "6194",
"284R": "2844",
"110": "1100",
"69": "0690",
"459Ltd": "4591",
"500Ltd": "5001",
"429": "4290",
"501Ltd": "5011",
"421": "4210",
"423": "4230",
"422": "4220",
"425": "4250",
"424": "4240",
"426": "4260",
"308": "3080",
"278R": "2784",
"301": "3010",
"302": "3020",
"303": "3030",
"304": "3040",
"305": "3050",
"307": "3070",
"262Ext": "2622",
"493Ltd": "4931",
"506Ext": "5061",
"132R": "1324",
"77": "0770",
"SPL-9": "8091",
"247R": "2474",
"SPL-5": "8051",
"505Ltd": "5051",
"SPL-6": "8061",
"SPL-1": "8011",
"SPL-3": "8031",
"SPL-2": "8021",
"499Ltd": "4991",
"496Ltd": "4961",
"508Ltd": "5081",
"388Ltd": "3881",
"235R": "2354",
"526Ltd": "5261",
"373Ltd": "3731",
"506Ltd": "5061",
"218R": "2184",
"173R": "1734",
"229": "2290",
"228": "2280",
"225": "2250",
"224": "2240",
"222": "2220",
"221": "2210",
"220": "2200",
"374Ltd": "3741",
"88": "0880",
"509Ltd": "5091",
"390": "3900",
"87Ltd": "0871",
"151": "1510",
"604": "6040",
"601": "6010",
"154": "1540",
"156": "1560",
"158": "1580",
"609": "6090",
"608": "6080",
"533Ltd": "5331",
"448Ltd": "4481",
"48": "0480",
"46": "0460",
"44": "0440",
"45": "0450",
"42": "0420",
"43": "0430",
"41": "0410",
"5": "0050",
"7Ltd": "0071",
"111R": "1114",
"618R": "6184",
"255Ltd": "2551",
"309Ltd": "3091",
"481": "4810",
"436R": "4364",
"473": "4730",
"477": "4770"
}