

def get_base_data():
    print('fetching Google spreadsheet to create base data')
    spreadsheet_id = '0AsuPWK1wtxNfdGdyVWU4Z3J3X3g3RzVyVWJ1Rkd4dXc'
    gs = GoogleDocsClient(google_email, google_password)
    wards = csv_file_to_dict(gs.download(spreadsheet_id, 1))
    ancs = csv_file_to_dict(gs.download(spreadsheet_id, 2))
    smds = csv_file_to_dict(gs.download(spreadsheet_id, 0))
    output = OrderedDict()
    for ward in wards:
        w = OrderedDict()
        output[ward['Ward']] = w
        w['ward'] = int(ward['Ward'])
        w['ancs'] = OrderedDict()
    for anc in ancs:
        a = OrderedDict()
        output[anc['ANC'][0]]['ancs'][anc['ANC'][1]] = a
        a['anc'] = anc['ANC'][0:2]
        a['anc_letter'] = anc['ANC'][1]
        a['smds'] = OrderedDict()
        a['committees'] = OrderedDict()
    for smd in smds:
        s = OrderedDict()
        output[smd['smd'][0]]['ancs'][smd['smd'][1]]['smds'][smd['smd'][2:]] = s
        s['anc'] = smd['smd'][0:2]
        s['smd'] = smd['smd']
        s['smd_number'] = smd['smd'][2:]
        s['ward'] = smd['smd'][0]
    return output

dataset/ETHPy150Open codefordc/ancfinder/scripts/update_anc_database.py get_base_data/original