def save_businesses():
    for bdata in iterate_file("business", shortcircuit=False):
        business = Business()
        business.business_id = bdata['business_id']
        business.name = bdata['name']
        business.full_address = bdata['full_address']
        business.city = bdata['city']
        business.state = bdata['state']
        business.latitude = bdata['latitude']
        business.longitude = bdata['longitude']
        business.stars = decimal.Decimal(bdata.get('stars', 0))
        business.review_count = int(bdata['review_count'])
        business.is_open = True if bdata['open'] == "True" else False
        business.save()

        save_categories(bdata['business_id'], bdata['categories'])
        save_neighborhoods(bdata['business_id'], bdata['neighborhoods'])
def save_businesses():
    for bdata in iterate_file("business", shortcircuit=False):
        business = Business()
        business.business_id = bdata['business_id']
        business.name = bdata['name']
        business.full_address = bdata['full_address']
        business.city = bdata['city']
        business.state = bdata['state']
        business.latitude = bdata['latitude']
        business.longitude = bdata['longitude']
        business.stars = decimal.Decimal(bdata.get('stars', 0))
        business.review_count = int(bdata['review_count'])
        business.is_open = True if bdata['open'] == "True" else False
        business.save()

        save_categories(bdata['business_id'], bdata['categories'])
        save_neighborhoods(bdata['business_id'], bdata['neighborhoods'])
示例#3
0
def save_businesses():
    for bdata in iterate_file("business", shortcircuit=False):
        business = Business()
        business.business_id = bdata['business_id']
        business.name = bdata['name']
        business.address = bdata['address']
        business.city = bdata['city']
        business.neighborhood = bdata['neighborhood']
        business.state = bdata['state']
        business.latitude = bdata['latitude']
        business.longitude = bdata['longitude']
        business.stars = decimal.Decimal(bdata.get('stars', 0))
        business.review_count = int(bdata['review_count'])
        business.is_open = True if bdata['is_open'] == "1" else False
        business.save()
        temp = bdata['attributes'] if bdata['attributes'] is not None else []
        temp1 = bdata['categories'] if bdata['categories'] is not None else []
        save_categories(bdata['business_id'], temp1)
        save_attributes(bdata['business_id'], temp)