问题描述
所以我正在尝试基于Google表格创建订阅比较器。 g表在第一行中具有订阅特征,每隔一行是订阅 (g sheets so you can see what I mean) 我尝试了不同方法,但没有找到,其中任何一个{{ 3}},但它发送了太多请求,因此API在100个请求/ 100秒后阻止了我。我还尝试将link / unlink方法应用于批处理命令,但它也不起作用。
因此,我需要您的帮助。我对python的了解非常了解。我已经下载了pygsheets,但实际上我不在乎要做什么。
如果您想要一个示例,它将是这样的:用户输入他想要的价格,移动数据的GB等价格,然后返回与他的条件匹配的订阅。在这里,我只是想解决第一部分,即具有符合条件的行。用户暂时没有输入标准问题。
解决方法
我不确定订阅比较器是什么意思。无论如何,根据您的链接查询,我已经更新了可接受的答案以减少api调用。
#list of all values in 4th/price column
prices=wks.get_cols(4)
#Remove nonnumeric characters from prices
prices=[p.replace('*','') for p in prices[1:]]
#Get indices of rows with price >=50
##i+2 to account for one indexing and removing header row
indices=[i+2 for i,p in enumerate(prices) if float(p)>=50]
#get these rows
rows = wks.get_values_batch([(str(x),None) for x in indices])