Created
October 12, 2019 09:14
-
-
Save yume-yu/de4cdc42c42704ab984fe2ab1a0af3bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
from pprint import pprint | |
from googleapiclient.discovery import build | |
# con = cg.ConnectGoogle() | |
TOKEN_FILENAME = "token.pickle" | |
creds = None | |
with open(TOKEN_FILENAME, "rb") as token: | |
creds = pickle.load(token) | |
service = build("sheets", "v4", credentials=creds) | |
request_doby = { | |
"dataFilters": [{"gridRange": {"startColumnIndex": 0, "startRowIndex": 1}}], | |
"majorDimension": "COLUMNS", | |
} | |
request = ( | |
service.spreadsheets() | |
.values() | |
.batchGetByDataFilter( | |
spreadsheetId="1iung0Vi3DNKOlb_IIV2oYya_0YjUsZaP2oBkjKekvbI", body=request_doby | |
) | |
) | |
response = request.execute() | |
pprint(response) | |
values_list = response.get("valueRanges")[0].get("valueRange").get("values") | |
id2name_dict = dict(zip(values_list[0], values_list[1])) | |
pprint(id2name_dict["U1ENCSW65"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment