简体   繁体   中英

Python/gspread module - Given a list of tuples representing coordinates, update all these cells with one single value?

Im struggling since yesterday with this problem, can't iterate too much cause I get rate limited by google, cause of perfomrnace, would also prefer not to even with an higher limit.

I have the following:

#list of tuples representing (row,col)
list_of_tuples = [(27, 2), (28, 2), (29, 2), (30, 2), (31, 2), (32, 2), (33, 2), (34, 2), (35, 2), (36, 2), (37, 2), (38, 2), (39, 2), (40, 2), (41, 2), (42, 2), (43, 2), (44, 2), (45, 2), (46, 2), (47, 2), (48, 2), (49, 2), (50, 2), (51, 2), (52, 2), (53, 2), (54, 2), (55, 2), (56, 2), (57, 2), (58, 2), (59, 2), (60, 2), (61, 2), (62, 2), (63, 2), (64, 2), (65, 2), (66, 2), (67, 2), (68, 2), (69, 2), (70, 2), (71, 2), (72, 2), (73, 2), (74, 2), (75, 2), (76, 2)]

#udpate these cells in the worksheet with  the string "DONE"
worksheet.update_cells(list_of_tuples, "DONE")

Can't really find something that could make it...

Thanks guys!!

Omg, finally:

    cell_range = worksheet.range(f'B{list_of_tuples [0][0]}:B{list_of_tuples [-1][0]}')
    for cell in cell_range:
        cell.value = "DONE"

    worksheet.update_cells(cell_range)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM