def add_googledoc_data(output):
    print("adding Google spreadsheet data")
    scraped = json.loads(open('data/scraped-anc.json').read())

    # Don't ever run this without also running the scraperwiki
    # data because scraperwiki overrides google doc data.
    
    # Create Google Documents client and download the spreadsheet as a CSV for each worksheet.
    spreadsheet_id = "0AsuPWK1wtxNfdGdyVWU4Z3J3X3g3RzVyVWJ1Rkd4dXc" # our spreadsheet
    gs = GoogleDocsClient(google_email, google_password)
    wards = csv_file_to_dict(gs.download(spreadsheet_id, 1)) # second argument is the worksheet ID
    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 __HOLE__:
            raise ValueError(anc["ANC"][0] + " is not an ANC.")
        a["website"] = anc["Website"]
        a["committees"] = OrderedDict() # clear
    
    # Use name from anc.dc.gov to check that we have the right commissioner
    # before overwriting with spreadsheet information
    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(s.get("Position"), str):
            # migrate this field to a list; once we're all migrated we should
            # move this conversion out of this if block and up to where we
            # update s.
            # We encode multiple positions using double asterisks in the spreadsheet.
            if s["Position"].strip() == "":
                s["Position"] = [] # empty list
            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