Python 3.9.7 with gspread 4.0.1 My script is run every 8 seconds and checks for new emails in this spreadsheet with empty status field (row1). And if empty - it subscribes the person. Also uses api to check email quality, and later updates fields with email quality scores. Python Gspread is used to interact with google sheets api.
Once a day or two i get this error.
{'code': 400, 'message': 'Range (LeadsFromTilda!F1632) exceeds grid limits. Max rows: 1631, max columns: 26', 'status': 'INVALID_ARGUMENT'}
But in breadcrumbs i see that request just before this erroneous one, was successful. and it was on 1632 !
Here is a relevant part of my code. Full version is available at codereview
gc = gspread.service_account_from_dict(credentials)
sh = gc.open("Tilda_Form_v4 emails")
ws = sh.get_worksheet(0)
def dotable():
all_values = ws.get_all_values()
for index, row in enumerate(all_values):
if row[1] == "subscribed" or row[1] == "error":
pass
elif row[1] == "":
rownum = index + 1
name = row[0]
email = row[5]
print(fr"Empty status {name},{email} on {rownum} ")
success, response = subscribe(email, name)
if success:
ws.update("C" + str(index + 1), 'moded_ok')
check_result_json = checkemail(email)
check_result = "Overall Score (bigger better) "+str(check_result_json["overall_score"])
ws.update("F" + str(rownum), check_result) # Result email check. Overall score
ws.update("H" + str(rownum), str(check_result_json)) # Result email check full data
ws.update("G" + str(rownum), parse_bmresponse(response))
break
else:
ws.update("C" + str(rownum), 'moded_noluck')
check_result_json = checkemail(email)
ws.update("H" + str(rownum), str(check_result_json)) # Result email check full
ws.update("G" + str(rownum), parse_bmresponse(response))
break # important notice here. Only 1 email per iteration. (google api limits)
else:
pass
while 1 > 0:
try:
dotable()
time.sleep(8)
What i tried to fix it:
- Changing sheet name. To "Tilda", "WokLeadsV1d", finally now it is "Tilda_Form_v4 emails" Advice from here
- Adding more rows or removing all empty ones. Still get this error. Now the end of the spreadsheet looks like that
Please help me fix this bug.