通过python gpread更新的数据显示在Gsheet中,但不显示在google Data studi中

2024-06-17 13:19:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经将谷歌工作表集成到谷歌数据工作室。当我直接在GS中手动输入值时,它会反映在GDS中。但当我使用python通过gspread模块在GS中输入值时。这些值反映在GS中,但不反映在GDS中

我尝试将GDS重新连接到GS,GDS反映了我手动输入的所有数据,而不是我通过python通过gspread更新的数据,但这些值反映在GS中

scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('Spreadsheet Data Interfacing-33971d4dec4c.json', scope)
client = gspread_authorize(creds)

def update_cells(p_worksheet, p_range, p_values):
    cell_list = p_worksheet.range(p_range)

    for i, val in enumerate(p_values):  
        cell_list[i].value = val  # use the index on cell_list and the val from cell_values

    p_worksheet.update_cells(cell_list)

除了GDS无法在任何图表(时间序列、记分卡)中显示数据,但我在GS中手动输入的值显示之外,一切都正常


Tags: 数据httpscomgscellrangeval手动