

def add_googledoc_data(output):
    print('adding Google spreadsheet data')
    scraped = json.loads(open('data/scraped-anc.json').read())
    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))
    committees = csv_file_to_dict(gs.download(spreadsheet_id, 10))
    for ward in wards:
        w = output[ward['Ward']]
        w['description'] = ward['Description']
    for anc in ancs:
        try:
            a = output[anc['ANC'][0]]['ancs'][anc['ANC'][1]]
        except KeyError:
            raise ValueError((anc['ANC'][0] + ' is not an ANC.'))
        a['website'] = anc['Website']
        a['committees'] = OrderedDict()
    for smd in smds:
        s = output[smd['smd'][0]]['ancs'][smd['smd'][1]]['smds'][smd['smd'][2:]]
        if (scraped[smd['smd']]['official_name'] == smd['official_name']):
            s.update(smd)
        if isinstance(cmte.get('Position'), str):
            if (s['Position'].strip() == ''):
                s['Position'] = []
            else:
                s['Position'] = s['Position'].split('**')
    for cmte in committees:
        c = OrderedDict()
        output[cmte['ANC'][0]]['ancs'][cmte['ANC'][1]]['committees'][cmte['committee']] = c
        c['committee'] = cmte['committee']
        c['meetings'] = cmte['meetings']
        c['chair'] = cmte['chair']
        c['chair_email'] = cmte['chair email']
        c['purpose'] = cmte['purpose']

dataset/ETHPy150Open codefordc/ancfinder/scripts/update_anc_database.py add_googledoc_data/VarMisuse@284/462 `s`->`cmte`