I apoligize in advance for the overly complicated code, this is just a segment of a larger part.
while True:
import bs4 as bs
import urllib.request
import re
import pygsheets
import httplib2
http_client = httplib2.Http(timeout=50)
gc = pygsheets.authorize(http_client=http_client, retries = 5)
sh = gc.open('PRNW API')
wks = sh.sheet1
import datetime
import time
time_x = [0,2,4,6,8,10,12,13,14,16,18,20,22]
weekday_list = [0,1,2,3]
y = 22
break
while True:
now = datetime.datetime.today()
while now.hour in time_x:
while now.minute == y:
if now.weekday() in weekday_list:
if now.minute == 22:
if now.hour == 12:
New_tries = 0
while New_tries <= 9:
try:
now = datetime.datetime.today()
x_date = str(now.date())
values_list = [x_date,x_date,x_date,x_date,x_date]
wks.insert_rows(row=0, number=1, values=values_list)
break
except:
New_tries += 1
time.sleep(30)
if New_tries == 10:
print('Could Not Upload New Day')Pysheets just inserts 10 blank rows into my google sheets API. 'Could Not Upload New Day' always prints, so I know this fails 10 times. It always fails and never succeeds. It has been 3 days in a row now. I don't understand how it can insert a row but not put content into that row when the command to insert a row and put content into it are all in the line:wks.insert_rows(row=0, number=1, values=values_list)It just kinda uploads blank rows and then goes from try to except. Correct me if I'm wrong, I'm new to Python, but this seems like something kinda uncommon. Anyways, I just want the date to be uploaded in every column in my google sheets at 12:22 P.M.. Instead, 10 blank rows end up in its place. Any help is appreciated.
