def cb(count,ds): school = None try: school = School.objects.get(gsid=ds["universal-id"]) except: school = School() # print "called for num:" + str(count) + "val: " + str(ds) school.name = ds["name"] school.gsid = ds["universal-id"] school.city = ds["city"] if len(ds["zip"]) > 6: ds["zip"] = ds["zip"][:6] school.zip = ds["zip"] school.state = ds["state"] school.lat = ds["lat"] school.lon = ds["lon"] school.gsurl = ds["url"] if len(ds["street"]) > 50: ds["street"] = ds["street"][:49] school.street = ds["street"] if len(ds["level"]) > 20: ds["level"] = ds["level"][:19] school.level = ds["level"] if len(ds["phone"]) > 20: ds["phone"] = ds["phone"][:19] school.phone = ds["phone"] if len(ds["subtype"]) > 50: ds["subtype"] = 'special' school.type = ds["subtype"] if len(ds["district-name"]) > 50: ds["district-name"] = ds["district-name"][:49] school.district_name = ds["district-name"] # try: print school.gsurl school.save()
def cb(count, ds): school = None try: school = School.objects.get(gsid=ds["universal-id"]) except: school = School() # print "called for num:" + str(count) + "val: " + str(ds) school.name = ds["name"] school.gsid = ds["universal-id"] school.city = ds["city"] if len(ds["zip"]) > 6: ds["zip"] = ds["zip"][:6] school.zip = ds["zip"] school.state = ds["state"] school.lat = ds["lat"] school.lon = ds["lon"] school.gsurl = ds["url"] if len(ds["street"]) > 50: ds["street"] = ds["street"][:49] school.street = ds["street"] if len(ds["level"]) > 20: ds["level"] = ds["level"][:19] school.level = ds["level"] if len(ds["phone"]) > 20: ds["phone"] = ds["phone"][:19] school.phone = ds["phone"] if len(ds["subtype"]) > 50: ds["subtype"] = 'special' school.type = ds["subtype"] if len(ds["district-name"]) > 50: ds["district-name"] = ds["district-name"][:49] school.district_name = ds["district-name"] # try: print school.gsurl school.save()
def cb(count,ds): school = School() school.name = ds["name"] school.gsid = ds["universal-id"] school.city = ds["city"] if len(ds["zip"]) > 6: ds["zip"] = ds["zip"][:6] school.zip = ds["zip"] school.state = ds["state"] school.lat = ds["lat"] school.lon = ds["lon"] if len(ds["subtype"]) > 50: ds["subtype"] = 'special' school.type = ds["subtype"] sql = 'insert into schools_school values ("'+ds["universal-id"]+'","'+ ds["name"] + '","' + ds["subtype"] + '","' + ds["city"] + '","' + ds["state"] + '","' + ds["zip"] + '","' + ds["lat"] + '","' + ds["lon"] + '",0);' print sql
def cb(count, ds): school = School() school.name = ds["name"] school.gsid = ds["universal-id"] school.city = ds["city"] if len(ds["zip"]) > 6: ds["zip"] = ds["zip"][:6] school.zip = ds["zip"] school.state = ds["state"] school.lat = ds["lat"] school.lon = ds["lon"] if len(ds["subtype"]) > 50: ds["subtype"] = 'special' school.type = ds["subtype"] sql = 'insert into schools_school values ("' + ds[ "universal-id"] + '","' + ds["name"] + '","' + ds[ "subtype"] + '","' + ds["city"] + '","' + ds["state"] + '","' + ds[ "zip"] + '","' + ds["lat"] + '","' + ds["lon"] + '",0);' print sql