i have this code, that checks color of each cell in a google sheets worksheet. that would be ok, but for 1200 rows, it takes 400 seconds to do so, so i wanted to ask if someone know of a better way to check color of a each cell in a column(i couldnt find how to check only 1 column, and not the whole sheet), and put it in a list? can i use get_all_values() for only 1 column?
import pygsheets
cells = cyber_worksheet.get_all_values(returnas='cell',include_tailing_empty=False, include_tailing_empty_rows=False)
color_code = []
for r in cells:
for c in r:
color_code.append(c.color)
return color_code
this worked, but very very slowly.... i was wondering if there was
I believe your goal is as follows.
In this case, how about using
get_colinstead ofget_all_values? When this is reflected in your script, how about the following modification?From:
To:
cyber_worksheet.get_col(1, returnas="cell", include_tailing_empty=False)tocyber_worksheet.get_col(2, returnas="cell", include_tailing_empty=False).cellsis a one-dimensional array, and each element is each row.Note:
If you use
get_all_values, how about the following modification?Reference: