在 For Loop Python 中更新 Google 表格单元格

问题描述 投票:0回答:0

我有一个 for 循环,它逐行从 google 工作表中读取信息,根据提供的信息登录到交换机并配置端口。我想补充一点,每次它遍历行中的数据时,都会在同一行的 Notes 单元格中写入 CONFIGURED。这是电子表格的示例:https://docs.google.com/spreadsheets/d/1Rg5Mhic8omQdlphIZNDPgbVBdLMj6WzPdmgz5XsJKb4/edit?usp=sharing

我正在使用 gspreads,当我这样做时,它只会更新第一个匹配单元格中的 CONFIGURED。

    sheet = file.open("SPREADSHEET")
    sheet = sheet.sheet1 

    mydata = sheet.get_all_records()

    datetoday = time.strftime('%m-%d-%y', localtime)

    for row in mydata:
        if row["Date"] == datetoday: 
            #
            #all the netmiko stuff to configure the port goes here
            #
            coordinates = sheet.find(datetoday)
            cell_info=("F"+str(coordinates.row))
            sheet.update(cell_info,"TEST")

python python-3.x google-sheets gspread
© www.soinside.com 2019 - 2024. All rights reserved.